Get the App
SLTechnology News&Howtos  ›  Development  › 

How to change the time zone to US East by php

Shulou Source: shulou.com Published: 2022-06-01 18:25:16 10月01日 Update

Most people do not understand the knowledge points of this article "how php changes time zone to US East", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can gain something after reading this article. Let's take a look at this "how php changes time zone to US East" article.

Modification method: 1, use "ini_set ('date.timezone',' America/New_York');" statement; 2, use "date_default_timezone_set ('America/New_York');" statement.

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

Division of time zone

The world is divided into 24 time zones, each of which has its own local time. At the same time, the local time of each time zone differs by 1: 23 hours. For example, the difference between London local time and Beijing local time is 8 hours.

In the field of international radio communications, a unified time is used, called Universal coordinated time (Universal Time Coordinated,UTC), and UTC is the same as Greenwich mean time (Greenwich Mean Time,GMT).

Php changes time zone to US East

1. Use the ini_set () function to set

The ini_set () function sets the value of the specified configuration option, which remains at the new value when the script runs and is restored at the end of the script. The syntax format of the function is as follows:

Ini_set ($varname, $newvalue)

Where $varname is the configuration option to be modified, and $newvalue is the new value of the configuration option.

Example:

Set the value of the date.timezonex entry to "America/New_York", that is, "United States / New York".

New York is in the east of the United States. New York is located in the northeast of the east coast of the United States, at the mouth of the Hudson River in southeastern New York, about halfway between Washington, D.C. And Boston, next to the Hudson River.

2. Use the date_default_timezone_set () function

The date_default_timezone_set () function sets a default time zone for all time and date functions in the script, and its syntax format is as follows:

Date_default_timezone_set ($timezone_identifier)

The parameter $timezone_identifier is a time zone identifier, such as UTC (Greenwich mean time) or Europe/Lisbon (Portugal).

Example:

The above is about the content of this article on "how to change the time zone of php to US East". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Time time zone function content United States East New York configuration script East hour article format knowledge example article sentence grammar Green same Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux Microsoft Shulou Technology Docker