1

I dont know why, but in some PCs the momentjs show a wrong time. I belive this caused by daylight summer (current here in my country). But in a few PCs show correctly and anothers with 1 hour of difference (like this print screen). Apparently the configuration of all PCs that I test are equals.

momentJS website

Updating: In a new check, I see that firefox x chrome are showing differents times. Seems the problem is just in Chrome.

Chrome x Firefox Time

On windows registry the values HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation are:

regedit print

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Times Zones doesn't exists on my Registry.

The Chrome navigator.userAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36

The Firefox navigator.userAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0

.

Márcio Rossato
  • 971
  • 1
  • 11
  • 20
  • 2
    It would be more helpful to show what code you are running, rather than the screenshot. Also it would be helpful if you told us what the time zone settings of the computer are. Type `tzutil /g` on the command line. Also while on this page, hit F12 in Chrome and type `moment().format()` in the dev console. Also type `new Date().toString()`. Put all those values in your question. – Matt Johnson-Pint Dec 07 '18 at 19:32
  • seems timezone configuration in the regional settings, hours is relative... the regional settings not.... Try a live linux...and same hour..show up in all PC... – Sk. Dec 07 '18 at 19:32
  • @Sk. tks for your replay. The timezone is equals in all PCs, but the hour has difference. – Márcio Rossato Dec 07 '18 at 19:40
  • @MattJohnson tks for your repply, I'm using windows server, but will put the console commands on question. tks – Márcio Rossato Dec 07 '18 at 19:44
  • @MattJohnson the chrome console is not working too. I belive some is bloking. tks – Márcio Rossato Dec 07 '18 at 20:06
  • What does `tzutil /g` return on the Windows command line? – Matt Johnson-Pint Dec 07 '18 at 20:11
  • @MattJohnson E. South America Stantard Time. The some in a both PCs. I Belive that the PC are wrong is sync time from a server. I sent a msg to administrator of the server. Because the PC are showing correctly is in another network. All PC in this network is showing incorrectly. – Márcio Rossato Dec 07 '18 at 20:30
  • Try changing the time zone to something else, then change it back. Also make sure automatic DST is enabled. Then close and reopen Chrome and try again. LMK if that works for you and I'll explain further. – Matt Johnson-Pint Dec 07 '18 at 20:52
  • @MattJohnson thanks for your support. Please look what I found (picture on ask). Chrome vs. Firefox is displaying a different time. – Márcio Rossato Dec 10 '18 at 17:12
  • Are you sure that `tzutil /g` didn't say `"E. South America Standard Time_dstoff"` on the affected computers? If DST is off, you may experience these things. Perhaps the time zone is simply set incorrectly? What part of Brazil are these computers in? – Matt Johnson-Pint Dec 10 '18 at 18:40
  • @MattJohnson, tks again for help-me. I updated the print screen with this information that you said. tzutil return South America Standard without Time_dstoff but, on windows configuration DST seems is ON. In Brazil I'm in UTC -3 (with DST ON then in this period UTC -2). In amost Timezone list, the my timezone you will see Brasilia or San Paolo (the both be official time brazilian) – Márcio Rossato Dec 11 '18 at 09:56
  • @MattJohnson, tks again for help-me. I updated the print screen with this information that you said. tzutil return South America Standard without Time_dstoff but, on windows configuration DST seems is ON. In Brazil I'm in UTC -3 (with DST ON then in this period UTC -2). In amost Timezone list, the my timezone you will see Brasilia or San Paolo (the both are official time brazilian) – Márcio Rossato Dec 11 '18 at 11:37
  • Sorry to keep asking more questions, but can you please give one more screenshot? Open `regedit.exe` and navigate to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation`, and screenshot all of the values in the right-hand pane. Separately, please tell me the value of the `TzVersion` in the key at `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones`, and also the version of Chrom, as reported either in the Help/About dialog, or by `navigator.userAgent` on the dev console. Thanks. – Matt Johnson-Pint Dec 11 '18 at 17:29
  • Hi @MattJohnson, I updated the question with this information. Thank you so much for helping me with this. I believe finding this details on the web would be almost impossible. – Márcio Rossato Dec 11 '18 at 19:32

2 Answers2

3

Thanks for providing all of the information in the question. Though, I'll say that in retrospect, this isn't really on topic for Stack Overflow, and would probably fit better on the SuperUser or ServerFault sites in the StackExchange network. Still, I think I can address your problem:

The main cause is what you wrote:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Times Zones doesn't exists on my Registry.

That means that somehow, for some reason, perhaps by some other piece of software or perhaps by a system administrator, that very important key has been deleted. That particular key is the root of the Windows time zone database, and contains "Dynamic DST" information - allowing the start and end of DST to vary from year to year. It is what allows a list of time zones to appear in the control panel to pick from. If indeed this key does not exist, then that list should appear empty.

Why you see Chrome an hour off, is because Chrome is internally taking the TimeZoneKeyName, and then trying to find the corresponding entry in time zone database. If it is found, then it can use the Dynamic DST from there to ensure that the JS Date object behaves correctly with regard to year-over-year changes.

The interesting part is when it is not found (because it's deleted on your machine), then Chrome doesn't apply the current year DST information that is in the keys that are present on your machine. It just assumes there is no DST. FireFox, on the other hand, appears to be falling back to use the current year DST information when the time zone database is missing.

Either way - you're dealing with undocumented behaviors because it is not a reasonable state for your computer to have that key deleted. There are lots of other things that won't necessarily work correctly (such as scheduling Outlook meetings with people in other time zones, for example).

Additionally, it appears from the screenshot of your registry, that the DaylightStart value is the one from 2017, when DST would start in October in Brazil. It now starts in November, so 00 00 0a 00 should be 00 00 0b 00 at the start of that value. This change was made in Windows with KB4093753, which doesn't appear to be present on your computer. This tells me that Windows Updates are not running on these computers. Perhaps your administrator is manually picking which updates to install, or perhaps they have not been updated at all.

With particular regard to time zones, understand that changes are unpredictable. The various governments around the world can and do change their time zone information, sometimes responsibly, sometimes haphazardly. Microsoft tracks changes to this data and produces updates for Windows accordingly. You can review these updates on the Microsoft TZ/DST blog, or in the "Updates that have been issued" section of KB914387. If you don't stay up to date, then you risk not having accurate time zone information. And if you delete the time zone registry keys as seen here, then all bets are off.

Also note that it's important to have current time zone information even for countries other than your own. Perhaps, for example, you may need to schedule a meeting with a person in another time zone. If your computer is not current with time zone data updates, then you may schedule that meeting incorrectly.

At this point, I would recommend installing the latest time zone update (regardless of country indicated) which is KB4468323 at time of writing this. Time zone updates are cumulative, so in theory installing this update should restore your missing registry key and fix the problem.

Alternatively, and probably better, just turn back on Windows Update. There are probably many, many more updates you are missing also.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • Thank you so much for all the help and for spending your time with my problem. In addition to clarifying my difficulty I also learned a lot of new things. Thanks! – Márcio Rossato Dec 12 '18 at 03:05
  • Initially I did not find the problem was in my operating system, but even if I knew I would not have asked in SuperUser or ServerFault because I did not know those sites. Thank you for introducing me to these other two sites, I will be attentive in the next few times to ask in the most correct place. – Márcio Rossato Dec 12 '18 at 03:17
  • Note that the correct full path to the key is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones, at least on my operating system. – azoundria Dec 27 '18 at 17:25
  • Ah, copy paste error I think. I had the key correct in the original comment. I'll update the answer, but now I wonder if Márcio actually has the data or not? @Márcio, look under `Windows NT`, not `Windows`. – Matt Johnson-Pint Dec 27 '18 at 17:37
  • Hi, @MattJohnson, how you helped me to identify that the problem was Windows configuration, I informed the support of that server and they (not me) updated the Windows and the problem was solved. – Márcio Rossato Jan 07 '19 at 16:50
  • This problem originaly was in Windows Server 2012. Also happened on my PC (Windows 7) because of this, some "prints" was from Windows 7 too. In both cases updating the Windows solved the problem. – Márcio Rossato Jan 07 '19 at 16:54
0

Maybe if you use moment().isDST() and act accordingly...

http://momentjs.com/docs/#/query/is-daylight-saving-time/

Marcus Sabino
  • 340
  • 1
  • 2
  • 9