How to set the US time zone in php

醉折花枝作酒筹
Release: 2023-03-09 11:06:01
Original
4812 people have browsed it

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');
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template