0

I have some unit tests failing with errors like:

  -  "dateModified": "Fri Mar 06 2015 00:00:00 GMT+0000 (UTC)"
  -  "datePublished": "Fri Mar 06 2015 00:00:00 GMT+0000 (UTC)"
  +  "dateModified": "Fri Mar 06 2015 00:00:00 GMT+0000 (GMT Standard Time)"
  +  "datePublished": "Fri Mar 06 2015 00:00:00 GMT+0000 (GMT Standard Time)"

One set of results in from node 6.5.0 on Unix, the other node 6.5.0 on Windows.

This is odd, as I was under the impression that UTC was GMT.

  • Is UTC the same thing as GMT?
  • If not, what is the difference?
  • Is one preferable to the other?

Some further tests setting the TZ environment variable:

Before changing the timezone:

$ node
> new Date().toString()
'Fri Sep 02 2016 17:14:36 GMT+0100 (GMT Daylight Time)'

After changing the timezone:

$ $env:TZ='UTC'
$ node
> new Date().toString()
'Fri Sep 02 2016 16:15:34 GMT+0000 (GMT Standard Time)'
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • They are not the same. UTC is the universal standard for dates and times. GMT is a time zone in England. UTC is preferable. – Heretic Monkey Sep 02 '16 at 15:49
  • @MikeMcCaughan GMT and UTCs value is the same, even if during the summer Britain observes BST instead of GMT. England doesn't have distinct time zones from the rest of the UK. More to the point: none of this matters without references. – mikemaccana Sep 02 '16 at 16:13
  • 1
    Which is why it was a comment, not an answer. I don't have the time or inclination to regurgitate the history of UTC, which [Wikipedia](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) can do for you just as easily as anyone else can. Perhaps some research by yourself is warranted if you're going to crack wise? – Heretic Monkey Sep 02 '16 at 16:33
  • @MikeMcCaughan Not cracking wise, just responding to an error: saying 'GMT is a time zone in England' is very, very obviously wrong and indicates you probably haven't read that page yourself. Citing wikipedia is incorrect, but if you wanted to do it anyway, you'd read "For most purposes, UTC is considered interchangeable with GMT" from that very page – mikemaccana Sep 05 '16 at 14:02

0 Answers0