When I use moment.js, in the environment of Node.js v7
var moment = require('moment');
console.log(moment());
will be printed in the console
moment("2017-06-23T09:06:56.216")
use
console.log(typeof moment());
Learn that moment() is an object
Sometimes, moment.js will also add some prompt words to the console.log, such as when using moment-timezone but not specifying the timezone of the second parameter
console.log(moment.tz('2013-06-01T00:00:00-04:00'));
will be printed on the console
Moment Timezone has no data for 2013-06-01T00:00:00-04:00. See http://momentjs.com
/timezone/docs/#/data-loading/.
moment.utc("2017-06-23T01:12:20.003+00:00")
Above, how to set the text printed by a javascipt object when console.log this object?
Because the
has been rewritteninspect
methodYou can try it under node:
Or you can try:
Recommend an article
https://shijianan.com/2017/04...
Just override the toString method.