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 to solve the "It is not safe to rely on the system's timezone settings" problem of php

2025-01-18 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" It is not safe to rely on the system's timezone settings "problem of php. In the operation of actual cases, many people will encounter such a dilemma. Then 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!

If you use a version above PHP5.3, if you do not configure php.ini correctly, there will be an error in the PHP date function. In the past, many old PHP programming tutorials did not talk about this problem, so many readers will be confused. Here are three ways to solve this problem.

"PHP Warning:

Date () [function.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 "

In fact, from PHP 5.1.0, when using functions such as date (), if timezone is set incorrectly, E_NOTICE or E_WARNING information is generated each time the time function is called. In PHP 5.1.0, date.timezone is off by default, and no matter what PHP command is used, it seems that this error will be thrown by force in PHP 5.3 if it is not set. To solve this problem, just localize it.

First, use date_default_timezone_set () to set date_default_timezone_set ('PRC') in the header; / / East 08:00 area echo

Date ('Y-m-d HRV iRV')

Second, use ini_set ('date.timezone','Asia/Shanghai') in the header

Third, modify php.ini (if it is a windows system, then the file is on disk C, Windows directory, if the system is installed on disk C). Use notepad to open php.ini to find date.timezone, remove the previous semicolon and change it to: date.timezone = PRC

Restart http services (such as apache2 or iis, etc.)!

You can choose one of the above three methods, and the editor recommends the third method without having to add extra code every time.

This is the end of the content of how to solve the It is not safe to rely on the system's timezone settings problem of php. 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.

Share To

Development

Wechat

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

12
Report