Is it possible in JavaScript to keep Date objects in different time zones, e.g.:
date1.toString();
>>> 2012-02-16T14:00+02:00
date2.toString();
>>> 2012-03-16T13:00+01:00
i.e. I have two date objects they reflect the same moment of the time but keep their information in different time zones.
No. Dates in JavaScript represent a moment in time; they do not store time zone information. You can then choose to display what time that represents in a particular timezone. (See the various methods like
getHours()—current local time zone—versusgetUTCHours().)To display a time in a timezone other than UTC or the local you need to write (or use) a function that does a bit of math:
Edit: You can choose to store a custom offset along with a date (as you can add custom properties to any JS object):