javascript - What is the timestamp reference after deducting from getTimezoneOffset()? -


for example have this:

d = new date(2013,04,20,14,56,10) mon may 20 2013 14:56:10 gmt+0800 (sgt) dt = d.gettime() /1000 1369032970 

now, timezoneoffset value is

d.gettimezoneoffset()*60 -28800 

so if reduce it, get

dt -= d.gettimezoneoffset()*60 1369061770 

my question is, 1369032970 local timestamp, , 1369061770 utc timestamp?

can safely current timestamp reduced timezoneoffset utc timestamp?

the result gettime in milliseconds since 1/1/1970 utc. local time zone plays no part in it. if question how utc timestamp, use result gettime without modification.

the idea of "local timestamp" isn't useful. 1 might apply offset utc timestamp before rendering human-readable date string - in javascript, that's done behind scenes. don't want pass numeric timestamp else unless strictly utc, because meaning of "local" lost.

also, when call gettimezoneoffset, getting specific offset @ moment represented date - in minutes. also, sign opposite of see time zone offsets. example, live in arizona offset utc-07:00 year-round. call gettimezoneoffset returns positive value of 420. if were apply timestamp, following:

dt -= dt.gettimezoneoffset() * 60 * 1000; 

you had it, forgot convert seconds milliseconds. said, value meaningless. if created new date object it, display offset applied twice - once own code, , again javascript internals.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -