<?php
function add_date($orgDate,$mth){
$cd = strtotime($orgDate);
$retDAY = date('Y-m-d', mktime(0,0,0,date('m',$cd)+$mth,date('d',$cd),date('Y',$cd)));
return $retDAY;
}
?>
<?php
setlocale(LC_TIME, 'nld_NLD');
$date = new DateTime();
$date->add(new DateInterval('P1M'));
echo strftime("%B %Y", strtotime($date->format('Y-m')));
?>
function get_month_year()
{
setlocale(LC_TIME, 'nld_NLD');
$date = new DateTime();
$date->add(new DateInterval('P1M'));
return strftime("%B %Y", strtotime($date->format('Y-m')));
?>
}
Re the comments on setLocale - it does require some tweaking depending on whether you are running on windows or Linux - but you should know which system you are runnign on and it is a trivial thing to be able to set the correct value. You could even write a bit of code that auto detects and calls the right parameter.The man page says, " Different systems have different naming schemes for locales." There are some illuminating and cautionary user-contributed notes on the man page!Also, this is kind of a grin... When was the last time you needed an update to the list of months? Not in my lifetime, IIRC :-)
better than having to maintain an array of months
<?php
phpinfo();
?>
Upload and call that script - version will be displayed at the top of the page. If running on less than 5.2 you might want to check if you can upgrade - PHP currently at version 5.4<?php
// Set locale string based on OS
$locale = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'nld_NLD' : 'nl_NL';
setlocale(LC_TIME, $locale);
$date = new DateTime();
$date->add(new DateInterval('P1M'));
echo strftime("%B %Y", strtotime($date->format('Y-m')));
?>
Slightly less longwinded than the accepted solution but does require 5.2 or higher
Open in new window