var date = new Date(1257397200000);
document.write(date);
Ran the code above I got Wed Nov 04 2009 23:00:00 GMT-0600 (Central Standard Time)
I am looking for a way to create date object based on different time zone, say for that time stamp I want to obtain date object like Thursday, November 5th 2009, 00:00:00 (GMT -5).
Note that the dates are different according to above two time zones, though they represent same point in time. I am in CST, is that why the created object is generated using CST?
Thank you.
No, these dates aren’t different as they don’t represent different point in time. The both represent
Thu, 05 Nov 2009 05:00:00 GMT.Dateobject in JavaScript is time-zone independent, it only represents point in time. The fact thatDate.toString()includes time zone is very misleading, there is no time-zone information inDate. It is only a wrapper around milliseconds since epoch.The time zone you see is based on OS/browser locale. You cannot create
Dateobject in different time-zone. Consider usinggetUTC*()family of methods to get browser time-zone agnostic values.BTW your example code prints:
on my computer – and this is still the same point in time.
See also