JavaScript dates - what is the difference between getMinutes() and getUTCMinutes()?

StackOverflow https://stackoverflow.com/questions/23641773

  •  22-07-2023
  •  | 
  •  

Вопрос

It seems like both functions return a number between 0 and 59.

Это было полезно?

Решение

There are a handful of timezones that are not offset by UTC by a multiple of hours, but have an additional half hour. You can see the list at Half hour time zones, and they include India, so it's not an insignificant portion of the world by any means. If you're in one of these timezones, getMinutes and getUTCMinutes of the current time will be 30 minutes different.

And there are two locations, Nepal and Chatham Islands, that have an additional 45 minutes in their offset from UTC.

Другие советы

One is based on the universal time (also known as GMT) one is relative time of the client. So the base they call from is different. I did find some time zones do have partial hours, so the minutes can be different.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top