user2061886 user2061886 - 9 months ago 35
Javascript Question

converting yyyy-mm in string format to a month name var javascript

if I had a string like this:

var dte = '2017-07'

how would I convert that to another var with a value of 'July'?


var dte = '2017-07'
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var another = months[+dte.split('-')[1] - 1]