Provide zblog template_zblog them_wordpress template download and customization

The solution to the time zone problem when wordpress uses strtotime

Tianxing Studio 2022-02-17 11:16 Wordpress Tutorial eight hundred and ninety-four 0 Comments


I'm writing a Wordpress Theme I found a problem in the background. The time set in the theme configuration does not match the timestamp output from the foreground. Then the direct foreground printing found a problem:

 $cs_time = strtotime('2022-01-17 09:00:00'); var_dump($cs_time);

The output is "1642410000". The time stamp is converted to "2022-01-17 17:00:00". The time difference is 8 hours.

After some searching, we know that "strtotime" will be transferred to the Greenwich time zone. The problem is wordpress "Shanghai" has been set in the backstage time zone setting (PS: I don't understand what the Shanghai time zone is. It is clear that China has only one Beijing time zone).

This is a problem of egg pain.

After a further search, no solution was found. Baidu's search results were all copied, including the cancer of csdn.

In the end, I really don't want to bother, and the violent solution:

If you have other solutions, please leave a message in the comment area of this article to discuss. If not, use this violent solution.

 $cs_time = strtotime('2022-01-17 09:00:00') - 28800; var_dump($cs_time);

Can't find a tutorial that can solve your problem?

You can try to search or ask questions directly online. We also provide charging technical support. If you need it, you can contact us online.

Online questions Online Service

welcome you Comment: Cancel Reply

 Please fill in the verification code
  • Latest articles
  • Hot article ranking
  • Most Comments
Label aggregation
  • Sign in
  • Registered account Forgot your password?
  • register
  • Already have an account? Direct login Forgot your password?
  • Social account login