What is the difference between toGMTstring() and toUTCstring()?

前端 未结 4 1304
醉梦人生
醉梦人生 2021-02-14 06:53

I am saving data in MongoDB server from Node.js application (using Mongoose).

Consider following code:

var mongoose = require(\'mongoose\');
var Schema =         


        
4条回答
  •  一个人的身影
    2021-02-14 07:28

    GMT and UTC are different timezones, they are Greenwich Mean Time and Coordinated Universal Time respectively. GMT is a 'solar' timezone, whereas UTC is 'atomic'. For most purposes they are essentially the same thing, however UTC is more 'universal'.

    Interestingly the documentation you point to for toUTCString still show a GMT output:

    var today = new Date();
    var UTCstring = today.toUTCString();
    // Mon, 03 Jul 2006 21:44:38 GMT
    

    For interchange of data between application I would prefer to use something like ISO8601, which uses the 'Z' suffix for UTC:

    2013-01-16T08:19Z
    

    Where the 'Z' confusingly stands for 'Zulu time'!

提交回复
热议问题