www.vegard.net

Update: A new version of this plugin is now available. All users are encouraged to upgrade to version 2.0. More information is available here.

My very first attempt on a WordPress plugin is actually just a copy/past job from my own CMS. I wanted to get functionality I could not find in any other plugins: I simply wanted to display the number of days since a post or page was published.

The plugin will only display years and days and will not take into account that 24 hours are one day. If you publish a page or a post at 23:59, it will be marked with “yesterday” at 00:00 even if it’s only a minute since you published. In some cases, the plugin will display a human readable text instead of the days count. Today is “today” and not “0 days ago”. Yesterday is, well, “yesterday”, while anything published seven days ago is posted “a week ago”. If an entry is more than a year old, the plugin will display the post date as “X year, Y days”.

If you want to use it yourself, simply follow these instructions:

  1. Download here (v1.0).
  2. Unzip the contents of the downloaded file to the /wp-content/plugins/ directory of your WordPress installation.
  3. Log in to your WordPress dashboard and activate the wp_days_ago plugin that should now be visible in the list.
  4. You can now insert <? wp_days_ago(); ?> anywhere in The Loop in your WordPress theme.

The wp_days_ago plugin takes one parameter; the timezone offset between your WordPress time zone settings and the server your WordPress installation is running on. In my case I write everything in Central European Time, but the server is located in Sydney, Australia. That’s a -8 hour time zone offset from the server to my local time, and to get things right, I have to use -8 as the time zone offset parameter, like this: <? wp_days_ago(-8); ?>.

This plugin is also available through the WordPress plugin directory.

8 comments
  1. WordPress Plugins: wp-days-ago at WordPress Today Saturday September 6th, 200813:19 CET

    [...]   wp-days-ago,提示文章或者页面是多少时间前撰写的。   用过twitter的朋友都知道twitter会提示你follow的朋友某条信息是多久前发出的,这个插件就是用来实现这样一个效果。当然作为Blog不用像twitter那样精确到秒或者分钟,本插件会提示文章是“今天” “昨天” “x天前” “上星期” “x年又x天”。 [...]

  2. mike Friday February 27th, 200919:46 CET

    i know this is an odd request, but would it be possible to make this backwards-compatible with WP 2.3.3?

  3. mike Friday February 27th, 200920:06 CET

    nm… found a relative date plugin =)

  4. krsnsk Wednesday May 13th, 200916:14 CET

    Thanx for plugin. You write in wordpress extend. can you edit it? http://wordpress.org/extend/plugins/wp-days-ago/installation/

  5. the life and work of tim walter » Blog Archive » a few days ago… Tuesday July 14th, 200902:11 CET

    [...] ich das plugin von vegard skjefstad installiert habe, ist mir bewußt geworden wie informativ diese darstellung der vergangenen tage [...]

  6. Jaycee Friday March 19th, 201003:19 CET

    I really love this plugin!! soo simple♥(^з^)

  7. asif Tuesday June 8th, 201012:50 CET

    love this plugin

    thanks

  8. cp Sunday September 26th, 201002:21 CET

    Started using this on my site for the top featured list. Very nice, tight plugin.

    Thanks for taking your time to make it!!!!

Submit comment

Recently played

Album Art for Quickly Disappearing

Quickly Disappearing

by Matthew Santos

7 hours ago

Album Art for Never Coming Home - 2011 Mix

Never Coming Home - 2011 Mix

by Sting

9 hours ago

Today in...

2010: Nexus One?
2007: Back at the Movies.
2006: Message.
2006: Winter Wonderland.
2005: Wedding.
2004: Port Knocking.