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

I save data in a MongoDB Node.js server (using Mongoose ).

Consider the following code:

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

var schemaObj = new Schema({
    field1: String,
    field2: String,
    Datefield: Date//So on...
});

mongooseDB = mongoose.createConnection('mongodb://myserver:port/DBname');
mongooseDB.on('error', console.error.bind(console, 'error in connection'));

mongooseDB.once('open', function (err) {
        var objmodel = db.model('myschema', schemaObj); 
        modelObj.field1 ='value1'; 
        modelObj.Datefield = new Date().toGMTString(); //new Date().toUTCString();
        //So on..
        modelObj.save(function (err) {
            if (err)    
                 //Notify err
            else
                //DO some task after save
        });

    });

In the date field, Getting the next value when I use 'toGMTstring ()' or 'toUTCstring ()'

 'Thu, 24 Jan 2013 05:49:04 GMT'

I looked at the following links:

toGMTString is deprecated and should no longer be used

Can someone help me in understanding what is the difference between toUTCstring () and toGMTstring () relative to Node.js?

+5
source share
2 answers

GMT UTC - , . GMT - "" , UTC - "". , , , UTC "".

, , toUTCString, GMT:

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

- ISO8601, 'Z' UTC:

2013-01-16T08:19Z

, "Z" " "!

+11

, , . MDN , toGMTString toUTCString:

toGMTString() . ; toUTCString().

0

All Articles