I am trying to use timezone-js to convert the timezone and get the correct time based on region. I am using following thread as reference. convert-date-to-another-timezone-in-javascript
But, when I set a time in constructor and change the timezone, it shows the same time.
I am not able to get the converted time based on the zone. I tried following.
var dt = new timezoneJS.Date("2013/07/02 18:59:00 +0000", 'Asia/Singapore');
alert('This is time call ' + dt.getTime() + dt.getTimezone());
dt.setTimezone("America/Argentina/Mendoza");
alert('This is new time call ' + dt.getTime() + dt.getTimezone());
Both shows me time as 1372791540000. Am I missing anything here?
Thanks Matt for the answer. That did give me the date. But, I am surely missing the concept to use this library. My understanding was that once I give a time and zone to the constructor, it will automatically adjust the UTC in the object, and next time I change the zone, it will provide me the correct time as per the zone.
e.g. - var dt = new timezoneJS.Date("2002/07/08 18:59:00 +0000", 'Asia/Singapore');
This gives me 2002-07-09 02:59:00
So, it is taking first argument(date) as the UTC and adjusting time accordingly. Is this correct behavior?
Then dt.setTimezone("America/Argentina/Mendoza")
;=>2002-07-08 15:59:00