my wordpress shows the wrong time, enter image description here

UTC time on the picture should be 18:06:28 and localtime 15:06:28, so the UTC time is showed as local time, I use my own vps on digital ocean and time zone is correct,

ls -l /etc/localtime
lrwxrwxrwx 1 root root 36 Apr 19 23:20 /etc/localtime -> /usr/share/zoneinfo/America/Santiago

also I have anothers php scripts on the server and the time is correct, cron job for whmcs for example works perfect, this is my config time on wordpress

enter image description here

How to fix this?, the problem is in all my wordpress websites, and the woocommerce websites has the wrong time on order too.

I use php 7 and last wordpress

I already tried with timezone in php.ini and in global php config I have America/Santiago

date on server is ok

root@server:~# timedatectl
      Local time: Fri 2018-04-20 22:15:40 -03
  Universal time: Sat 2018-04-21 01:15:40 UTC
        RTC time: Sat 2018-04-21 01:15:40
       Time zone: America/Santiago (-03, -0300)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

php too

php > echo date_default_timezone_get(time());
America/Santiago

This might be a solution for you: https://wordpress.org/support/topic/utc-time-and-local-time-problems/

It says that it's a problem with PHP config, not Wordpress.

(Bringing the solution here for ease of reference)

  1. If you have shell access, do you get the correct date/time when you type “date” at the command line? If that’s wrong, contact your host.

  2. Try adding the correct timezone to php.ini: http://www.inmotionhosting.com/support/website/php/setting-the-timezone-for-php-in-the-phpini-file (And check if that is displaying the right zone)

  3. Check your plugins, if any of them modifies anything on Wordpress clock. On the link I sent above the case was solved by deactivating a calendar plugin.

Both these links below can help with your search too, I can't point at what could solve it since there's missing information on this topic about what they say there, but I hope it shine some light into your problem!

https://wordpress.org/support/topic/utc-time-wrong/page/2/

Fixing UTC time - wordpress effects

  • hello, 1) date shows local time correctly 2) already did, a php.ini file on wp folder and php global config with correct timezone (america/santiago). 3) no new plugin installed, I have woocommerce, yoast, wp rocket, I dont use jetpack – Osvaldo Parra Apr 21 at 1:11
  • 1
    +1 for properly putting the text here instead of forcing people to follow the links ;) – Mark Kaplun Apr 21 at 5:51
  • @OsvaldoParra did you check if it's showing the correct timezone on info.php? This answer on one of the links proposes to add a php script that displays UTC time to test further: wordpress.org/support/topic/utc-time-wrong/page/2/#post-8654937 Try this in a PHP script. Not in WordPress, just a standalone script on your server. date_default_timezone_set( 'UTC' ); echo date('Y-m-d G:i:s'); That should, obviously, output the UTC time. Does it? Also, thanks @MarkKaplun ;) – atempel Apr 23 at 17:45
  • @atempel no, it doesnt, that line shows local time, check la-maria.cl/test/info.php, time on info.php is local time – Osvaldo Parra Apr 24 at 22:15
  • @OsvaldoParra It should show the time you configured on php.ini. Try to set the timezone in php.ini as 'UTC' and keep the configuration on Wordpress with your local timezone. Wordpress has it's own system for time managing, so it might assume that the default time on PHP is UTC, and since you changed it, it displays wrong on the front-end. – atempel Apr 25 at 21:03

Trying searching through all files in your /wp-content/ folder for any reference to this function:

date_default_timezone_set

If a theme or plugin manually defines this it can throw off your WP installation. I had a circumstance exactly like the one you describe here, and the source was this line at the top of the theme's functions.php file:

date_default_timezone_set( 'America/New_York' );

This resulted in the wrong UTC time reported under Settings > General:

Universal time (UTC) is 2018-10-05 12:05:18. Local time is 2018-10-05 08:05:18.

Once removed, the correct times appeared:

Universal time (UTC) is 2018-10-05 16:06:01. Local time is 2018-10-05 12:06:01.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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