
Originally Posted by
tomyknoker
PHP Code:
$monthText = date("F", mktime(0,0,0,$theMonth+1,0,0));
By specifying the date as zero (0) - an out-of-range value - the calculated date is rolled back one day into the preceding month.
If your main objective is to obtain the month as a string, I would have thought it would be computationally less expensive to use:
PHP Code:
$monthNames = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$date = getdate();
$monthText = $monthNames[($date['mon'] + 10) % 12];
or at the very least:
PHP Code:
$date = getDate();
$monthText = date('F', mktime(0, 0, 0, $date['mon'] - 1));
Mike
Bookmarks