Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php remove the warning when getting the current date

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how php removes the warning when getting the current date. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Php gets rid of the warning when getting the current date: 1, set the value of date.timezone to PRC;2 in php.ini, cancel the comments before the date.timezone=PRC code; 3, restart apache.

This article operating environment: windows10 system, php 7, thinkpad T480 computer.

A warning similar to the following may occur when getting the current date:

PHP Warning: date (): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set () function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for' 8.0/no DST' instead in D:\ PHPWEB ews\ file.php on line 17.

This is because the time taken by PHP is Greenwich mean time, so it will be different from your local time. The difference between Greenwich mean time and Beijing time is about 8 hours. We can solve the problem according to the following methods:

1. Use date_default_timezone_set () in the header to set my default time zone to Beijing time.

2. In php.ini, set the value of date.timezone to PRC, set it to date.timezone=PRC or date.timezone= Asia/Shanghai, and uncomment this line of code, that is, remove the previous semicolon.

Then restart apache.

This is the end of the article on "how to get rid of the warning when getting the current date in php". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report