If..Else Log

The time of day and wp-admin

I’m currently using the time of day plugin to modify the post times to a more human friendly format. However, users may have also noticed that the timestamps in the wp-admin interface are also modified. This is because, the plugin works via the filter hooks provided WP which processes output before displaying it to the user. The particular filter hook that I’m using (the_time) filters the output of the_time() functions.

Whilst this is used in most people’s index.php file, it is also used in the wp-admin/edit.php file, and thus the dates here will also be filtered.

There is however a workaround: WP 1.5 provides another function get_the_time() which has two slightly different properties. Instead of displaying the time, this function now returns it. The second (and for us, the more crucial) property is that it isn’t processed by the_time filter. Hence what we can do is to make the wp-admin/edit.php use this call instead and we’d have the best of both worlds.

In your wp-admin/edit.php, change the following line:
the_time('Y-m-d \<\b\r \/\> g:i:s a');
echo get_the_time('Y-m-d \<\b\r \/\> g:i:s a');

If you don’t feel comfortable making the changes yourself and you’re using WP 1.5, you can download my amended edit.php file. Rename your current wp-admin/edit.php to wp-admin/edit.php.old, upload this modified version and rename it as edit.php.


10 Responses to “The time of day and wp-admin”

  1. Gravatar Dan

    I can die happy. My blog will now reach nirvana.

  2. Gravatar Phu

    Glad you found it useful:-)

  3. Gravatar Dan

    Hi again, again.

    I was browsing around my site to see if everything was cool (which it *is*, of course!) and I noticed that when I went into the archives, instead of saying “Archive for February 2005″ as the title it was saying “Archive for in the early evening”, even though it was actually for Feb ’05.

    I imagine this is the same oddness as before, and I think the same way to fix it is in the way you suggested for the Admin interface. I haven’t tested it out though, for now I’m just going to deactivate the plugin.

    If I find that it’s actually the same problem then I’ll let you know and what lines I had to change!

  4. Gravatar Chris

    Great plugin…

    I have a slight problem though, no matter when I make a post, it always says “wee hours…”?!

    Also, after activating the plugin, some of my posts will not show the date after your plugin runs. Any thoughts? Thank you!

  5. Gravatar pdberger

    I am having the same problem. But I also have an additional problem, which is that my times have disappeared completely from my site (www.pdberger.com). I also noticed that when I activate the plugin, my date disappears. I think this plugin is a great little addition. I’d really appreciate it if you can help me get it to work. (apologies if this request looks familiar — I thought I have already posted similar but I can’t find the thread!)

  6. Gravatar Phu

    Could have a look to see if your theme is calling the_time via:
    instead of the_time('F j, Y');

    To show the date as well, what you’ll need to do is use the_date tag i.e.
    the_date('','<h2 class="entrydate">','</h2>');

    Some themes are incorrectly using the_time tag to display the date as opposed to the_date, which is why it may not appear.

    Alternatively, you can also download the previous release. More information on that release can be found here.

  7. Gravatar pdberger

    Hi Phu. I really appreciate you getting back to me, but I am afraid that I am just not technically good enough to fix this. I’m not sure where to insert the code


    (I had a play around but i just made things worse. And I’m afraid I did not fare much better installing the older version.

    Thanks again though. I think I need a few crash courses in code and WP in order to survive :)

  8. Gravatar hparm

    Some themes are incorrectly using the_time tag to display the date, which is why it may not appear.

    According to the codex you are supposed to use the_time for dating your posts. I think this is why people are having trouble with your plugin.

  9. Gravatar rwphillips.com to do/wish list at rwphillips.com

    [...] Fix this time of day plugin. Front page reports that all posts written “Just after midnight”. Look here [...]

  10. Gravatar Balaji Dutt

    Hi Phu,

    I have installed the Timeofday plugin, along with the edit page hack and it works fine in these pages.

    However, when I view my archive, instead of the month, I see “in the wee hours” everywhere. My theme (Collage Effect) just uses wp_get_archives function, which AFAIK, uses the function the_time(‘F j, Y’);.

    Could you please tell me how I can get the Archives to show the month correctly?