Reputation: 165
I added an input type=month
in my page and I am getting the value using jquery as per example 2017-08
.
How can I transform it to August, 2017
?
Upvotes: 0
Views: 92
Reputation: 137
You could use moment.js to achieve this:
moment('2017-08', 'YYYY-MM').format('MMMM, YYYY');
Upvotes: 2
Reputation: 34914
You can make a array of month name and use like this
allMonths = ["January", "February", "March","April", "May", "June", "July","August", "September", "October","November", "December"];
var date = new Date("2017-08");
var month = date.getMonth();
var year = date.getFullYear();
console.log(allMonths[month]+", "+year);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Upvotes: 2