Wed Jul 06 2022 14:42:13 GMT-0400 (Eastern Daylight Time)
This format is the default format that is output "Independent of input format" from new Date()
.
2022-07-15T00:00:00.000Z
or 2015-03-25
console.log(moment(new Date()).toISOString());
// 2022-07-06T19:08:36.670Z
console.log(moment(new Date()).toString());
// Wed Jul 06 2022 15:08:36 GMT-0400
console.log(new Date());
// Wed Jul 06 2022 15:08:36 GMT-0400 (Eastern Daylight Time)
console.log(new Date().toString());
// Wed Jul 06 2022 15:08:36 GMT-0400 (Eastern Daylight Time)
You can see that moment(new Date()).toISOString()
and moment(new Date()).toString()
DO NOT output that same format as the default JS format.
moment(new Date()).toString()
is close, but is still missing the (Eastern Daylight Time)
which is part of the default.console.log(moment(new Date()).toDate());
That was way harder to find than it should have been.
console.log(moment(new Date()).toDate());
// Wed Jul 06 2022 15:25:52 GMT-0400 (Eastern Daylight Time)
console.log(new Date());
// Wed Jul 06 2022 15:25:52 GMT-0400 (Eastern Daylight Time)
console.log(new Date().toString());
// Wed Jul 06 2022 15:25:52 GMT-0400 (Eastern Daylight Time)
console.log(moment(1234, moment.ISO_8601, true).isValid());
// true
console.log(1234 instanceof Date)
// false
console.log(new Date() instanceof Date);
// true