Reputation: 23
I get date value from my source in this format: 02.08.2016 / Day.Month.Year, it's correct.
but JavaScript understand this inverse, Month.Day.Year.
I tried some ways with Moment.js like:
moment('15.08.2016').format('MM.DD.YYYY');
My JsFiddle is: http://jsfiddle.net/PAc3j/389/ There are some results visible, see please output, variable dateThree: Invalid date
My question is, how can I do it with Moment.js or classic JavaScript?
Upvotes: 2
Views: 2627
Reputation: 161
You can specify the format of the input date string like this.
moment('15.08.2016', 'DD.MM.YYYY').format('MM.DD.YYYY');
http://momentjs.com/docs/#/parsing/string-format
Upvotes: 4