Convert date in YYYY/MM/DD format in MomentJS

javascript, momentjs

Solution

You can try this:

moment('2010/12/01', 'YYYY/MM/DD').format('DD/MM/YYYY')

Problem

I am using MomentJS for converting the date format. I have a date in this format 2010/12/01 and I want to convert it to 01/12/2010 using MomentJS only. I have another date in this format "12/02/2014" and I want to convert in "2014/12/02" ``` <!--begin snippet: js hide: false console: true babel: false--> <!--language: lang-js--> var date = moment(new Date(2010/12/01)).format("MMM Do h/mm"); console.log(date); <!--language: lang-html--> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script> <!--end snippet--> ``` How do I convert them using MomentJS

Original source