Home > Article > Backend Development > How to set Beijing time in php
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.
#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!