Home > Article > Backend Development > How to set php time zone to Berlin?
Method: 1. In the php.ini configuration file, set "date.timezone="Europe/Berlin"" and restart the environment; 2. Use "ini_set('date.timezone' in the header of the PHP page ,'Europe/Berlin')" to set the time zone.
Recommended: "PHP Video Tutorial"
Three ways to set Berlin time zone in PHP
Method 1:
Add the date.timezone item found in php.ini and set date.timezone = "Europe/Berlin "
, restart the environment and it will be ok.
Method 2:
When you need to use these time functions, add date_default_timezone_set("Europe/Berlin");
# to the page
##Method 3:
Add setting time zone to the header of the pageini_set('date.timezone','Europe/Berlin');
List of legal time zones: http://www.php.net/manual/en/timezones.phpSummary, methods one and three generally require server permissions is more effective, and method 2 allows technicians to control the current page, which is also a more commonly used method among programmers. Related recommendations:
The above is the detailed content of How to set php time zone to Berlin?. For more information, please follow other related articles on the PHP Chinese website!