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.

made jsfiddle in case don't it.


Comments

Popular posts from this blog

java - Unable to make sub reports with Jasper -

sql - The object name contains more than the maximum number of prefixes. The maximum is 2 -

scala - play framework: Modules were resolved with conflicting cross-version suffixes -