javascript - String value with moment.js -
my js:
... var datetext=''; datetext = moment(scope.mtxmaxdate,'mm-dd-yyyy'); console.log(datetext); ...
i want output value example: '12/12/2014'
in console have:
moment {_isamomentobject: true, _i: "17/12/2014", _f: "mm-dd-yyyy", _isutc: false, _pf: object…}
why..?
as stated in momentjs docs should use .format()
function.
something should :
var datetext='12-12-2014'; var dateobject = moment(datetext,'mm-dd-yyyy'); console.log(dateobject.format('dd/mm/yyyy'));
the format give argument on second line parse format.
i updated code, fact use angular or not doesn't change thing. think not understand moment js generates object string date. can format date object want.
Comments
Post a Comment