javascript - Why is toJSON() missing on my momentjs Object? -
i have been getting strange effect, it's momentjs works, doesn't.
this version 1.7.2, running in node.js.
reg.date = moment('230420050000','ddmmyyyyhhmm' ).tojson(); typeerror: object sat apr 23 2005 00:00:00 gmt+0200 (cest) has no method 'tojson' question 1: not proper way instantiate momentjs object?
when dump console, see has typical moment fields:
{ _d: { fri, 22 apr 2005 22:00:00 gmt _a: [ 2005, 3, 23, 0, 0, 0, 0, undefined ] }, _isutc: false, _a: [ 2005, 3, 23, 0, 0, 0, 0, undefined ], _lang: false } question 2: why did tojson() vanish?
answer 1:
acorinding error
object sat apr 23 2005 00:00:00 gmt+0200 (cest)
the initialization correct.
answer 2:
the tojson method supported version 2.0.0: http://momentjs.com/docs/#/displaying/as-json/
Comments
Post a Comment