Lara Ch Lara Ch - 5 months ago 21
jQuery Question

Transform the number returned from input type month into text

I added an

input type=month
in my page and I am getting the value using jquery as per example
How can I transform it to
August, 2017

Answer Source

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=""></script>