-6

I'm building an application in JavaScript that uses UTC time. It's very important that the time will always be the correct UTC time.

My application is going to be hosted on Amazon-ec2.

I use moment.utc() to get the UTC time.

Are there any known issues with the timezone on Amazon when the clock's changing to summer/winter time?

Can I sleep well knowing that whenever Amazon moves to winter time, it will immediately display the correct UTC time?

I'm asking that because on Microsoft Windows in my personal computers sometimes I need to change the local clock to summer/winter time by myself, and sometimes it switched back to winter time on the wrong day.

Notice: UTC time doesn't change, but it's calculated according to the computer local time, and the computer local time does change, so an incorrect local time ends up with an incorrect UTC time.

Alon
  • 10,381
  • 23
  • 88
  • 152
  • 2
    You do know that UTC is not affected by daylight savings time (e.g.: it doesn't change for summer/winter)? – UnholySheep Oct 21 '16 at 13:18
  • UTC does not have daylight savings time, it is always UTC – ndonohoe Oct 21 '16 at 13:18
  • 3
    Possible duplicate of [Does UTC observe daylight saving time?](http://stackoverflow.com/questions/5495803/does-utc-observe-daylight-saving-time) – tektiv Oct 21 '16 at 13:19
  • UTC doesn't change, I know that. But moment.utc() calculates the UTC time according to the computer local time. – Alon Oct 21 '16 at 13:20
  • @Tektiv you didn't read my question carefully. I didn't ask about UTC time, but about Amazon local time. The alleged UTC time is calculated locally by the operating system according to local time. Please remove the "duplicated question". – Alon Oct 21 '16 at 13:23
  • @ndonohoe please read my "Notice" paragraph. I've added it to help you to understand the question. – Alon Oct 21 '16 at 13:27
  • @Tektiv please read my "Notice" paragraph. I've added it to help you to understand my question. – Alon Oct 21 '16 at 13:28
  • @UnholySheep please read my "Notice" paragraph. I've added it to help you to understand my question. – Alon Oct 21 '16 at 13:28
  • 1
    @Alon you are missing the point everyone is trying to tell you. The calculation of UTC time is independent of any summer time/daylight savings time offset. The calculation of UTC time uses the local clock, but it doesn't use the local timezone. This should be easy for you to test. Please don't post questions without testing and verifying that you have an actual issue first. – Mark B Oct 21 '16 at 13:59
  • @MarkB I just tested it on my personal Ubuntu 14, and saw that when I change the clock time 2 hours ahead, the UTC time also changes to 2 hours ahead. The offset is left correct but the UTC is wrong!! So the UTC time that my moment.utc() returns is not independent from my computer local time. If the local time is wrong I'll get a UTC wrong too. BTW they didn't try to tell me what you said, they just assumed I was asking about "UTC summer time". You can see it by the "duplicated question" Tektiv referred me to. – Alon Oct 21 '16 at 14:39
  • 2
    You totally misunderstand. You changed the clock, not the summer time offset. UTC is based off the clock, not the summer time offset. Your question is about the offset not changing at the correct time, and we are saying that that will have no effect on UTC calculation. You didn't test the situation in your question. I specifically said that UTC is based on the system clock, not the timezone. Try changing your time zone or disabling summer time and see if UTC changes. – Mark B Oct 21 '16 at 15:08
  • 2
    Also, is this code running on the server or in the browser? If it's in the browser then why are you asking about AWS server time? If it's server-side code, then just set the server timezone to UTC if you are so worried about summer time changes. – Mark B Oct 21 '16 at 15:12
  • @MarkB my code runs on server side, and I'll make sure the server timezone is set to UTC. Thanks! – Alon Oct 22 '16 at 17:35

1 Answers1

2

Copied from AWS user guide:

Amazon Linux instances are set to the UTC (Coordinated Universal Time) time zone by default

Furthermore:

Network Time Protocol (NTP) is configured by default on Amazon Linux instances; however, an instance needs access to the Internet for the standard NTP configuration to work. In addition, your instance's security group rules must allow outbound UDP traffic on port 123 (NTP), and your network ACL rules must allow both inbound and outbound UDP traffic on port 123. [...] If your instance does not have access to the Internet, you need to configure NTP to query a different server in your private network to keep accurate time.

matsev
  • 32,104
  • 16
  • 121
  • 156