I got this error when I requested to update the PHP version from 5.2.17 to PHP 5.3.21 on the server.
<? print(gmdate("Y")); ?>
instead of
<? print(date("Y")); ?>
worked for me (shows current year and no more shows the error message). (Thanks to Chris above)
A simple method for two time zone.
<?php
$date = new DateTime("2012-07-05 16:43:21", new DateTimeZone('Europe/Paris'));
date_default_timezone_set('America/New_York');
echo date("Y-m-d h:iA", $date->format('U'));
// 2012-07-05 10:43AM
?>
<? date_default_timezone_set('Europe/Istanbul'); ?>
For php (or your location).
This issue has been bugging me for SOME time as im trying to inject a "createbucket.php" script into composer and i keep being told my time-zone is incorrect.
In the end the only thing that fixed the issue was to:
$ sudo nano /etc/php.ini
Search for timezone
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = UTC
Ensure you remove the ;
Then finally
$ sudo service httpd restart
And you'll be good to go :)
I had to put it in double quotes.
date_default_timezone_set("America/Los_Angeles"); // default time zone
If you don't have access to the file php.ini
, create or edit a .htaccess
file in the root of your domain or sub and add this (generated by cpanel):
<IfModule mime_module>
AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
<IfModule php5_module>
php_value date.timezone "America/New_York"
</IfModule>
<IfModule lsapi_module>
php_value date.timezone "America/New_York"
</IfModule>