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:
Đăng nhận xét