Millisecond to various GMT timezones conversion

javascript, timezone

Solution

Here i can get the desired output

var milliseconds=1274203800000;
var offset=10;
var d = new Date(milliseconds+(3600000*offset));
alert(d.toUTCString());

Initial Input:  Tue, 18 May 2010 17:30:00 GMT
Desired Output: Wed, 19 May 2010 03:30:00 GMT

Problem

I have a time in millisecond i.e. 1274203800000, now i want to convert it into GMT + 10 in javascript. currently i am using following code to do that ``` var milliseconds=1274203800000; var offset='+10'; var d = new Date(milliseconds); utc = d.getTime() + (d.getTimezoneOffset() * 60000); nd = new Date(utc + (3600000*offset)); var result=nd.toLocaleString(); alert(result); ``` Above code evaluates to "Wednesday, May 19, 2010 3:30:00 AM" date but this is not the correct output as "Tuesday, May 18, 2010 3:30:00 AM" (not sure about the AM or PM in this case) is the right one. But i don't know whats the problem over here. My current localtimezone is GMT+0530.

Original source