One simple thing I keep having to do over and over again is to display the name of the month for a given date. Normally I have opted to use the first solution that comes to mind which is creating an array with all the month names in it and then when I want to retrieve the month name I just use
$monthName = $aMonth[$monthNum];
However, when I wanted to use PHP to display the month name this time I wanted to see if there was a better solution.
The one I came across was posted on The Code Cookbook and was a simple 1 line statement which was great… simpler, neater and far more elegant than my usual method and it looked like
$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
Normally I would have been happy with this, however was needing to deal with a month drop down box which didn’t run from January to December but instead ran from November to April but this worked out to be rather simple too.