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 - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -