Home >Backend Development >PHP Problem >How to set Beijing time in php

How to set Beijing time in php

藏色散人
藏色散人Original
2021-02-23 10:30:583551browse

How to set Beijing time in php: first find and open the "php.ini" configuration file; then find "date_default_timezone_set" and set its value to "Asia/Shang" or PRC.

How to set Beijing time in php

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

php sets Beijing time

This requires using the date_default_timezone_set() function to set the time zone in different regions

For example: date_default_timezone_set('PRC');/ /Where PRC is "People's Republic of China" (Etc/GMT-8 and Asia/Shanghai can also represent Beijing time zone time)

At this time, use echo date('Y-m-d H:i:s', time( )); //The current time output is Beijing time.

Attach the time zone identifier:

CETCST6CDTCubaEETEgyptEireESTEST5EDTEtc/GMTEtc/GMT+0Etc/GMT+1Etc/GMT+10Etc/GMT+11Etc/GMT+12Etc/GMT+2Etc/GMT+3Etc/GMT+4Etc/GMT+5Etc/GMT+6Etc/GMT+7Etc/GMT+8Etc/GMT+9Etc/GMT-0Etc/GMT-1Etc/GMT-10Etc/GMT-11Etc/GMT-12Etc/GMT-13Etc/GMT-14Etc/GMT-2Etc/GMT-3Etc/GMT-4Etc/GMT-5Etc/GMT-6Etc/GMT-7 Etc/GMT-8Etc/GMT-9Etc/GMT0Etc/GreenwichEtc/UCTEtc/UniversalEtc/UTCEtc/ZuluFactoryGBGB-EireGMTGMT+0GMT-0GMT0GreenwichHongkongHSTIcelandIranIsraelJamaicaJapanKwajaleinLibyaMETMSTMST7MDTNavajoNZNZ-CHATPolandPortugalPRCPST8PDTROCROKSingaporeTurkeyUCTUniversalUTCW-SUWET。

Recommended: "PHP Video Tutorial"

The above is the detailed content of How to set Beijing time 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