
Untitled
By: a guest on
Jul 17th, 2012 | syntax:
None | size: 0.47 KB | hits: 16 | expires: Never
Javascript Converting human time to timestamp
var d = new Date("Wed Jun 20 19:20:44 +0000 2012");
d.getTime(); //returns 1340220044000
//OR
Date.parse("Wed Jun 20 19:20:44 +0000 2012"); //returns 1340220044000
//if you want to truncate ms instead of rounding just use Math.floor()
Math.round(Date.parse("Wed Jun 20 19:20:44 +0000 2012") / 1000); //returns 1340220044
//Gets date in seconds
var d1 = Date.parse('Wed Jun 20 19:20:44 +0000 2012')/1000;
alert(d1);