Reputation: 85
How can I change a date from the form 01/01/02 to January 1st, 2002?
Can I do this in javascript? If not, jQuery?
Upvotes: 3
Views: 38
Reputation: 42054
Using momentjs:
var x = moment('01/01/02', 'mm/dd/YYYY').format('MMM Do, YYYY');
console.log(x);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>
Upvotes: 1
Reputation: 12837
While you can certainly write your own date formatting routine, your best choice is using a library like moment.js. That is especially true if you'd be doing some manipulations to those dates besides just displaying them. Dates are hard to do and there are many things to consider (i.e. timezones)...
Upvotes: 2