If using php5.3 or higher,If php.ini is not configured correctly, a php date function error will occur.Many old PHP programming tutorials didn't mention this problem before,So many readers will feel confused,Below I will tell you three ways to solve this problem.
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 like date (),If timezone is set incorrectly,Every time the time function is called,E_notice or e_warning information will be generated. And in PHP 5.1.0, the date.timezone option,It is off by default,No matter what php command you use is Greenwich Mean Time,But it seems that if php 5.3 is not set, this error will be forcibly thrown.Solve this problem,Just localize it.
One,Use date_default_timezone_set () in the header to set date_default_timezone_set ("prc");//Eastern time zone echo
date ("y-m-d h:i:s");
two,Use ini_set ("date.timezone", "asia/shanghai") in the header;
three,Modify php.ini (If it is a windows system, the file is in the C drive and the windows directory, if the system is installed in the C drive). Use Notepad to open php.ini to find date.timezone. Remove the semicolon and modify it to:date.timezone=prc
Restart the http service (such as apache2 or iis, etc.)!
You can choose any one of the above three methods.We recommend the third method,No need to add extra code every time.
- python 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- android studio - unresolved reference comes out in kotlin
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- python - importerror: cannot import name md5 error cannot be resolved