I have a date string of the format dd-mm-yyyy hr:min:sec (time in 24 hour format). How do I convert this string into unix time. I know in php if I write time()
gives me unixtime. I am trying to achieve the same result from the date string using javascript.
var expTime = document.getElementById("expiryDT").value;
//the value inside this element is the date with (dd-mm-yyyy hr:min:sec) format.
var todayUnixTime = Math.round(+new Date()/1000);
//this gives me the unixtime in seconds for today, ready to pass into php
How do I convert the string expTime
into a unixtime in javascript, so that I can pass it to php;
var expTime = String(document.getElementById("expiryDT").value);