Tag Archives: Time Stamp

Calculating Relative Time Stamps With PHP and WordPress

If you go to a social networking site like Twitter, you’ll note that status updates don’t have conventional timestamps on them. Instead of something overly informative (in most cases) like “Posted 2010/07/06 7:50 PM” they tend to show the much more human-friendly “Posted 2 days ago” format for recent dates. These relative time stamps are useful in many cases because of how people think about time. If someone tells you that a new book is going to be released on some date. You immediately think “that’s 3 weeks from today.” Relative time stamps take that extra step out.

Now what do you need to do to display relative time stamps? It’s very simple in WordPress, using the human_time_diff() function. Things are a little bit harder for other projects, where you don’t have the luxury of using the pre-existing WordPress functions.

PHP Snippets has a copy-and-paste-able function that works in much the same way. It takes a UNIX timestamp as an input and uses the “granularity” option you set to find the difference between the times, then returns a string.

Historical Timestamps in WordPress

Jayvee Fernandez recently wrote on The Blog Herald about WordPress and it’s problems with historical timestamps.

A friend on Plurk asked whether it is possible to use actual historical dates on your blog’s CMS (i.e. 4th of July 1776 for Independence Day). I did some digging and there are posts that address this question.

While this is a neat idea, setting the post date to reflect the time period a work was created (e.g. a photo taken in 1985), it introduces some problems.

  1. You won’t be able to schedule posts to be published at a later date. Setting the timestamp to a historical date will cause it to go live immediately.
  2. Posts with historical dates won’t necessarily be seen on the homepage when they are published. As WordPress (by default) orders posts by date, users would have to browse the archives to find the post. If you’re a master of custom queries, you might be able to remedy it in some way.
  3. I’ve always thought of the post timestamp being the date of publication, not the date of the content’s creation.

Continue reading →

Schedule Your Posts

How do you blog currently? Do you just enter your post and hit publish? Sure, that works fine, but there’s a better way.

Most blog software includes a Time Stamp feature that allows you to write your post ahead of time and have it appear on your blog at a pre-scheduled time. Using this feature you can make blogging easier.

How often do you post something to your blog? Every day? Every other day? For simplicity, I’ll assume you post to your blog every day. What if you were unable to blog for a day (for whatever reason)? Some your readers wouldn’t like that too much. You can avoid that using the Time Stamp option.

At the beginning of the week, write a few posts and set them to post on the following days. Now you can do other things over the rest of the week. You can write more posts for the next week, you can work on some linkbait, or you could play Pirates of the Caribbean Online. :D

Continue reading →