Home  >  Article  >  Backend Development  >  How to set php time zone to Berlin?

How to set php time zone to Berlin?

青灯夜游
青灯夜游Original
2020-09-28 14:47:372370browse

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.

How to set php time zone to Berlin?

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 page

ini_set('date.timezone','Europe/Berlin');

List of legal time zones: http://www.php.net/manual/en/timezones.php

Summary, 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:

php training

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn