0

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.

enter image description here

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?

  • 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 May 17 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 May 17 at 23:55
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.