admin管理员组

文章数量:1193775

I look at the debug.log file a lot while developing, and having all the timestamps in UTC drives me crazy! How can I get them to display in local time? I have my php.ini 'date_timezone' value set to 'America/Los_Angeles' already.

I look at the debug.log file a lot while developing, and having all the timestamps in UTC drives me crazy! How can I get them to display in local time? I have my php.ini 'date_timezone' value set to 'America/Los_Angeles' already.

Share Improve this question asked Oct 16, 2015 at 23:12 eljefejbeljefejb 6512 gold badges7 silver badges16 bronze badges 3
  • Same problem here.. have you figured out how to do this? – neoDev Commented Jan 22, 2018 at 8:11
  • Nope. Neither WordPress nor PHP settings seem to have any effect. :( – eljefejb Commented Jan 22, 2018 at 16:38
  • @neoDev, in case you never figured this out, I just posted my answer below with a code snippet that you can use as an alternative – Michael Commented Jan 22, 2021 at 21:27
Add a comment  | 

3 Answers 3

Reset to default 2

What is the time zone setup in your admin -> settings -> general page? WordPress overrides & kind of disregards php's timezone & uses this own settings , if haven't set this - default is UTC+0

Update: according to https://core.trac.wordpress.org/ticket/39595 - wordpress has forced this to be UTC

You can retrieve the debug.log, convert the dates yourself, and display the results in your admin area.

I did this for a plugin I made, but have changed the code slightly to display the debug.log in a custom Dashboard widget so someone else can use it.

It will also highlight lines that contain issues from the functions.php file, as well as an additional keyword through a query string search. The code can be found here:

https://gist.github.com/mrgandy/8b6c198d8abf30d3f4e9def7300cc60c

Just set the preferred timezone in functions.php. That's it.

date_default_timezone_set('Asia/Kolkata'); 

Change 'Asia/Kolkata' with your preferred timezones. PHP Official timezone

It's recommended to use child-theme to preserve changes made in functions.php even after the theme gets updated.

本文标签: How to make debuglog timestamps local time