Quote:
Originally Posted by felgall
Since the OP didn't post their solution I'll provide one for anyone looking at how to load a unixtimestamp into JavaSScript.
var dt = new Date(unixtimestamp);
A unistimestamp is one of the valid formats that can be used to set the initial value for a JavaScript Date object.
|
Ummm....are you sure on that?
How would JS tell the difference, then, between a Unix timestamp (which is in *seconds*) and a JavaScript
Date.getTime() value (which is in millliseconds).
That is:
Code:
var unixtime = 1357027200;
var d1 = new Date(unixtime);
var d2 = new Date(unixtime*1000);
document.write( d1 + "<br/>" + d2 );
Produces:
Code:
Fri Jan 16 1970 08:57:07 GMT-0800 (Pacific Standard Time)
Tue Jan 01 2013 00:00:00 GMT-0800 (Pacific Standard Time)
Just a tiny bit of difference.
I think you meant to say that
Code:
var dt = new Date(unixtimestamp * 1000);
will do the job??