WordPress detects the wrong timezone

Both my server local time and timezone are correct (UTC -3).$ date -uFri May 17 23:53:01 UTC 2019$ date -Is2019-05-17T

Both my server local time and timezone are correct (UTC -3).

$ date -u
Fri May 17 23:53:01 UTC 2019

$ date -Is
2019-05-17T20:53:10-03:00

$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 37 May 17 20:41 /etc/localtime -> /usr/share/zoneinfo/America/Sao_Paulo

$ cat /etc/timezone 
America/Sao_Paulo

However, WordPress thinks my server is on UTC timezone and dials back 3 hours.

Timezone

Choose either a city in the same timezone as you or a UTC timezone offset.

Universal time (UTC) is 2019-05-17 19:38:06. Local time is 2019-05-17 16:38:06.

This timezone is currently in standard time. Daylight saving time begins on: November 2, 2019 11:00 pm.

How do I fix this?

Both my server local time and timezone are correct (UTC -3).

$ date -u
Fri May 17 23:53:01 UTC 2019

$ date -Is
2019-05-17T20:53:10-03:00

$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 37 May 17 20:41 /etc/localtime -> /usr/share/zoneinfo/America/Sao_Paulo

$ cat /etc/timezone 
America/Sao_Paulo

However, WordPress thinks my server is on UTC timezone and dials back 3 hours.

Timezone

Choose either a city in the same timezone as you or a UTC timezone offset.

Universal time (UTC) is 2019-05-17 19:38:06. Local time is 2019-05-17 16:38:06.

This timezone is currently in standard time. Daylight saving time begins on: November 2, 2019 11:00 pm.

How do I fix this?

Share Improve this question edited May 17, 2019 at 23:53 That Brazilian Guy asked May 17, 2019 at 22:43 That Brazilian GuyThat Brazilian Guy 1,2413 gold badges19 silver badges43 bronze badges 3
  • Possibly related: wordpress.stackexchange/questions/301392/… – That Brazilian Guy Commented May 17, 2019 at 22:54
  • Is the local time correct though? Keep in mind it will always tell you the time in UTC, there's a difference between a timestamp and a time/date. timestamps are always in UTC, you choose an offset and everything is offset on the fly. If your server is setting UTC time to your local time then that will cause major problems – Tom J Nowell Commented May 17, 2019 at 23:06
  • @TomJNowell I'm not sure if I follow. Who's this "it" that will always show the time in UTC? WordPress? PHP? The server itself? Doesn't date -Is guarantee that I'm getting the local time? Doesn't the T20:53:10-03:00 part indicates that? Am I mistaken here? Or do you mean something else? – That Brazilian Guy Commented May 17, 2019 at 23:55
Add a comment  | 

1 Answer 1

Reset to default 0

Turns out there was a previous attempt to fix the timezone:

date_default_timezone_set('America/Sao_Paulo');

was called on the init hook.

When later the correct UTC time, local time and timezone were properly set on the server, this caused a conflict.

Removing this solved the issue.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745483353a4629657.html

相关推荐

  • WordPress detects the wrong timezone

    Both my server local time and timezone are correct (UTC -3).$ date -uFri May 17 23:53:01 UTC 2019$ date -Is2019-05-17T

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信