Converting Date and Time To Unix Timestamp Converting Date and Time To Unix Timestamp unix unix

Converting Date and Time To Unix Timestamp


If you just need a good date-parsing function, I would look at date.js. It will take just about any date string you can throw at it, and return you a JavaScript Date object.

Once you have a Date object, you can call its getTime() method, which will give you milliseconds since January 1, 1970. Just divide that result by 1000 to get the unix timestamp value.

In code, just include date.js, then:

var unixtime = Date.parse("24-Nov-2009 17:57:35").getTime()/1000


Seems like getTime is not function on above answer.

Date.parse(currentDate)/1000


You can use Date.getTime() function, or the Date object itself which when divided returns the time in milliseconds.

var d = new Date();d/1000> 1510329641.84d.getTime()/1000> 1510329641.84