Maxi M. Maxi M. - 2 months ago 7x
Javascript Question

Date format with Moment.js or classic JS, change places of day and month?

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:


My JsFiddle is:
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?


You can specify the format of the input date string like this.

moment('15.08.2016', 'DD.MM.YYYY').format('MM.DD.YYYY');