Home > Article > Backend Development > How to set the US time zone in php
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.
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:
Declare the file type and encoding for PHP to interact with the browser, as shown in the figure:
The function of date_default_timezone_set() function: Set the default time zone, as shown in the figure:
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:
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!