Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of time error obtained by php time function

Shulou Source: shulou.com Published: 2022-06-03 10:37:55 11月15日 Update

Today, I will talk to you about how to solve the problem of getting time errors in the php time function, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

Php time function to get the time error solutions: 1, set the default time zone to be used; 2, open php.ini to find "date.timezone" and remove the previous semicolon; 3, add the initialization statement of time in the program.

This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer

How to solve the problem of time error obtained by php time function?

The solution to the error of using date function to get the current time in php

If you are new to PHP to do a website, if you want to get the current time on the page, anyone who has studied programming knows to use the time function date (). First, use this function to format a local time / date, and write a test code first. As a result, the output time is 8 hours less than the actual time. What is the reason for this:

The code is as follows:

Tags: Time function time zone error program problem code content hour output example semicolon method actual server website statement Beijing service awesome Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Xiaomi Shulou Information vpn Linux