javascript - Moment not formatting this date May 04, 2016 -
the server giving me date format may 04, 2016
var month = moment('may 04, 2016', 'mm-dd-yyyy').format('m')
month
gives me 4
, may should 5
, it's giving me day seems, , not month.
how format date server gives me determine month using moment.js?
edit:
not sure why downvoted tried answer below , still get
when give moment
2 string arguments, the documentation says second meant format of first. mm-dd-yyyy
not format of may 04, 2016
. format of may 04, 2016
mmm dd, yyyy
:
console.log(moment("may 04, 2016", "mmm dd, yyyy").format("m"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
Comments
Post a Comment