JavaScript: Creating timestamps with time zone offsets

Source: https://dzone.com/articles/javascript-creating-timestamps

Date.getTime() returns UTC

When you call getTime method on Date object you get the number of milliseconds from Unix epoch. Although your current Date object keeps time with some offset getTime gives seconds in UTC. Keep this in mind when creating timestamps if you are not living on zero-meridian.
var currentDate = selectedDate;          // current date with offset

var currentTime = currentDate.getTime(); // offset is ignored
This is pretty awkward, unexpected and unintuitive behavior but you have to keep in mind that all date and time calculations must use same time system to give appropriate results.

Không có nhận xét nào:

Cold Turkey Blocker

 https://superuser.com/questions/1366153/how-to-get-rid-of-cold-turkey-website-blocker-get-around-the-block Very old question, but still wan...