In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the thinkphp3.2 how to set the time zone related knowledge, detailed and easy to understand, simple and fast operation, has a certain reference value, I believe everyone will read this thinkphp3.2 how to set the time zone article will have some gains, let's take a look at it.
Methods of setting time zone: 1. Set time zone in "php.ini" configuration file, change the content of "date.timezone" item and remove ";" before the item;2. Use "date_default_timezone_set()" function to set time zone, specify the specified time zone in the parameter.
Operating environment: Windows 10 system, ThinkPHP3.2 version, Dell G3 computer.
Thinkphp3.2 How to set time zone
If your servers are located in different regions or countries, it is possible that some applications are located on servers that are far apart from the regions visited, resulting in inaccurate server time.
For the same timestamp, if the time zone is different, the resulting date time string will also be different. Therefore, setting the correct time zone is essential.
Different time zones affect the value of date ('Y-m-d H:i: s', time()) or similar functions.
We can do this by setting the default time zone.
The approximate location for changing the time zone is as follows:
1. Set the time zone in the PHP.INI configuration file:
The file location is/usr/local/php/etc/php.ini
date.timezone = PRC
2. Set the time zone in the code:
2-1. File location: /api/public/init. php
date_default_timezone_set ('Asia/Phnom_Penh')//required: Cambodia timezone
Common time zones are as follows:
a). date_default_timezone_set ('Asia/Shanghai');//'Asia/Shanghai' Asia/Shanghai
b) date_default_timezone_set ('Asia/Chongqing');//where Asia/Chongqing' is "Asia/Chongqing"
c) date_default_timezone_set ('PRC ');//where PRC is "People's Republic of China"
d) ini_set('date.timezone','Etc/GMT-8');
e) ini_set('date.timezone','PRC');
f) ini_set('date.timezone','Asia/Shanghai');
d) ini_set('date.timezone','Asia/Chongqing');
After many tests: It is recommended to use date_default_timezone_set here to set the time zone, the effect is obvious.
2-2. File location: /application/Common/Conf/config. php
'DEFAULT_TIMEZONE'=>'Asia/Phnom_Penh',//Time zone settings: Cambodia Time zone
3. Modify server computer time settings
Function comments in the above code:
definition and use
1.date_default_timezone_set(timezone) function Sets the default time zone used by all date/time functions in the script.
Parameter: timezone: Required. Specify the time zone to use, such as UTC or Europe/Paris.
List of legal time zones: http://www.php.net/manual/zh/timezones.php
2. ini_set is used to set the value of php.ini, which takes effect when the function is executed, and expires after the script ends. You can modify the configuration without opening the php.ini file, which is very convenient for virtual spaces.
Function Format:
string ini_set(string $varname, string $newvalue)
At this point, all the settings for modifying the time zone are complete, and the php time is consistent.
About "thinkphp3.2 how to set the time zone" this article content introduced here, thank you for reading! I believe everyone has a certain understanding of "thinkphp3.2 how to set time zone" knowledge. If you still want to learn more knowledge, please pay attention to the industry information channel.
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.