I come across a little tip the other day from Relative dates for posts and commentsin wordpress to get your WordPress posts date in a relative time format, like Twitter (1 min, 1hour, 1day ago), anyway you know what I mean.

The trick is to add a filter and function to you themes function file, so in your WordPress admin go to ‘Appearance > Editor’ and choose your current theme, on the right there is a list of page in your theme click on the Theme Functions one (functions.php). and add:

But there seemed to be a error in this it was returning my date/time from as though I wrote it at midnight, as the post at Revood was written in 2011 so I thought it might be a little out of date, so a little digging on Google and I found the answer to be in the human_time_diff function, this function takes two arguments, the ‘form date’ and the ‘to date’ so the trick is to get the time that the post was published and subtract the current time from that, now we don’t need to do this as WordPress has the function human_time_diff which does it for us so the updated snippet:

Now I have relative date/times on my post.

Hope you enjoy!