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

前端 未结 4 1290
醉梦人生
醉梦人生 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:36

    Mostly use for formatting date and time (Human Readable). You can also use toLocaleDateString()

    var event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
    
    var options = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' };
    
    console.log(event.toLocaleDateString('en-US', options));
    

提交回复
热议问题