Is there a a better solution than what I have below to convert a month name to a month number using JavaScript or PHP?
I did like this:
$monNum = date('n',strtotime($staff->curMonth));
Is there a a better solution than what I have below to convert a month name to a month number using JavaScript or PHP?
I did like this:
$monNum = date('n',strtotime($staff->curMonth));
You could keep an object of key/value pairs where the key is the month name and the value is the month number:
var months = {
January: 1,
February: 2,
...
};
and then:
var monthNumber = months['April'];
or:
var monthNumber = months.April;