In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to solve the problem of getting time out of time in php". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Php access time does not match the solution: 1, open the php.ini configuration file, and modify "date timezone = PRC"; 2, add date_default_timezone_set () function.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
What if the php acquisition time is not right?
Incorrect date and time for PHP acquisition
To get straight to the topic, after obtaining the time through the date () function, you will find that the hour time is wrong, 8 hours less than the current time, whether using H or h, this is because the current acquisition is Greenwich time, the difference between Beijing time and Beijing time is 8 hours.
The solution is as follows:
1. Modify php.ini configuration file
Open the php.ini file, generally in the php configuration root directory, find the; date.timezone, delete the previous semicolon, and change it to date timezone = PRC. Save and restart the Apahce service (sometimes there will be problems with restart, just stop and then start).
2. Add the date_default_timezone_set (timezone_identifier) function
What this function means is to set the current time zone, initialize the time, and add this sentence before the header or get time statement.
For example:
Date_default_timezone_set (PRC)
Echo date ("Y-m-d H-i-s")
The parameters are set as follows:
Date_default_timezone_set (PRC)-set to Beijing time, PRC represents the people's Republic of China
Date_default_timezone_set ('Asia/Shanghai')-set to Shanghai time, and' Chongqi' (Chongqing) and 'Urumqi' (Urumqi) are also available on the mainland.
Available in Hong Kong and Taiwan: Asia/Macao, Asia/Hong_Kong, Asia/Taipei (Macau, Hong Kong, Taipei in turn)
Singapore area: Asia/Singapore (I don't seem to see Beijing)
This function will always return True, but be sure to enter timezone_identifier, otherwise an error will be reported.
Here are all the time zone identifiers: (for your reference)
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-7Etc/GMT-8Etc/GMT-9Etc/GMT0Etc/GreenwichEtc/UCTEtc/UniversalEtc/UTCEtc/ZuluFactoryGBGB-EireGMTGMT+0GMT-0GMT0GreenwichHongkongHSTIcelandIranIsraelJamaicaJapanKwajaleinLibyaMETMSTMST7MDTNavajoNZNZ-CHATPolandPortugalPRCPST8PDTROCROKSingaporeTurkeyUCTUniversalUTCW-SUWET "how to solve the problem of php getting time pair This is the end of the content of "not on". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.