Tag Archives: datetime

#php #dates

how to add a year to a php date


$oneyear = strtotime("+1 year");

PHP 5.2

$date = getdate();
$oneyear = mktime(
echo $oneyear;
echo PHP_EOL;

PHP 5.3

$oneyear = date_timestamp_get(
        date_interval_create_from_date_string('1 year')));
echo $oneyear;
echo PHP_EOL;

#php ini file #date & #timezone settings

dont forget to edit your php.ini file and add a prefered date timezone to prevent apache httpd php warnings such as:

PHP Warning:  date(): It is not safe to rely on the system's timezone 
settings. You are *required* to use the date.timezone setting or 
the date_default_timezone_set() function. 

In case you used any of those methods and you are still getting 
this warning, you most likely misspelled the timezone identifier. 

We selected 'Europe/London' for 'BST/1.0/DST' instead

see also