Relative Dates for WordPress
Get the source (v1.01; changelog from v1.0)
Relative Dates is a simple plugin for WordPress that displays the date of your posts as the time elapsed since it was posted (based on the date that the user is viewing the post; i.e., "Posted 2 weeks, 1 day ago").
The code is aware of leap years and the fact that some months have more days than others.
Demo
I'm actually using the plugin on this site; see either the index page or any of the archived posts from the past month.
Installation and Implementation
- Place the relativedates.phps file into your /wp-content/plugins/ directory.
- Change the file extension from ".phps" to ".php".
- See the timezone section below only if your web server is in a different timezone than where your weblog "lives."
- Activate the plugin from the WordPress admin panel.
- Call the Relative Dates function like so (obviously from inside the WordPress Loop):
<?php relativeDate(get_the_time('YmdHis')) ?>
Timezone Information
Locate the following line near the top of the source:
$tz = 0;
Web server is to the east of your weblog
Change 0 to the difference (in hours) between your server's timezone and your weblog's timezone (note that this number should be positive). For example, if your server is in NY, but you live in CA, you would replace the 0 with 3.
Web server is to the west of your weblog
Change 0 to the difference (in hours) between your server's timezone and your weblog's timezone (note that this number should be negative). For example, if your server is in CA, but you live in NY, you would replace the 0 with -3.
Support
Hopefully you won't experience any problems, but feel free to e-mail me if you do.