How to convert date format to DD MMMM YYYY from Moment.js

22,236

The problem is that momentjs is not understanding the input format, so pass the input format to momentjs(string, string)

var string = moment('18/01/2016', 'DD/MM/YYYY').format("DD MMM YYYY")
result.innerHTML = string;
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.js"></script>
<pre id="result"></pre>
Share:
22,236
Priyank
Author by

Priyank

I am a senior software engineer developing a web and mobile application. My Skill set is Angular, Ionic, PhoneGap, Ios, Worklight (MobileFirst), Xamarine, PHP, Jquery/Javascript, Mysql, MongoDB... keep learning :)

Updated on February 11, 2020

Comments

  • Priyank
    Priyank about 4 years

    Getting Invalid date, if we try to format the date from moment.js.

    Code moment('18/01/2016').format("DD MMM YYYY"))

    Required Output : 18 jan 2016

    but getting invalid Date.

    Please Help