Home  >  Article  >  Backend Development  >  How to set the US time zone in php

How to set the US time zone in php

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-04-14 15:21:124810browse

In php, "date_default_timezone_set()" can be used to set the United States time zone, and the syntax is "date_default_timezone_set('America/New_York')", where "America/New_York" represents the eastern United States.

How to set the US time zone in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer.

Create a new TimeZone.php file, as shown in the figure:

How to set the US time zone in php

Declare the file type and encoding for PHP to interact with the browser, as shown in the figure:

How to set the US time zone in php

The function of date_default_timezone_set() function: Set the default time zone, as shown in the figure:

How to set the US time zone in php

will TimeZone.php is set to US time

date_default_timezone_set('America/New_York');
echo date('Y-m-d H:i:s');

Run the web page and you can see the US time, as shown in the picture:

How to set the US time zone in php

Recommended Learn: php video tutorial

The above is the detailed content of How to set the US time zone in php. 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