UTC date and time to local?

You should be able to convert the UTC timestamp into a local date and just subtract the local offset (which is in minutes), so.

You should be able to convert the UTC timestamp into a local date and just subtract the local offset (which is in minutes), so: function utcToLocal(utc){ // Create a local date from the UTC string var t = new Date(Number(utc)); // Get the offset in ms var offset = t. GetTimezoneOffset()*60000; // Subtract from the UTC time to get local t. SetTime(t.getTime() - offset); // do whatever var d = t.getFullYear(), t.getMonth(), t.getDate().

Join('/'); d += ' ' + t. ToLocaleTimeString(); return d; } Where I am, the offset is -600, so I need to subtract -36,000,000 ms from UTC time (which actually adds 36,000,000 ms).

The t object is capable of automatically forming the date string with the locale settings, there is no need for timezone offset calculations. – Igor Zinov'yev Sep 14 '11 at 7:41 1 @Igor - given the OP, utc is just a number, how does JS know that it is a UTC time and not local? Date instances are based on the local timezone, so the time of the created date object needs to be adjusted for the offset.

ECMA-262 15.9.1.9 is relevant. – RobG Sep 14 '11 at 9:19.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions