Relative Dates for WordPress
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.
Installation and Implementation
- Unzip the plugin file into your /wp-content/plugins/ directory.
- 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')) ?>
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.
Hopefully you won't experience any problems, but feel free to e-mail me if you do.