Inspect2.16.0+

  1. moment().inspect();

Returns a machine readable string, that can be evaluated to produce the samemoment. Because of the name its also used in node interactive shell to displayobjects.

  1. moment().inspect() // 'moment("2016-11-09T22:23:27.861")'
  2. moment.utc().inspect() // 'moment.utc("2016-11-10T06:24:10.638+00:00")'
  3. moment.parseZone('2016-11-10T06:24:12.958+05:00').inspect() // 'moment.parseZone("2016-11-10T06:24:12.958+05:00")'
  4. moment(new Date('nope')).inspect() // 'moment.invalid(/* Invalid Date */)'
  5. moment('blah', 'YYYY').inspect() // 'moment.invalid(/* blah */)'

Note: This function is mostly intended for debugging, not all cases arehandled precisely.