One of the many challenges we’ve encountered during our work on SitePoint Contests and Marketplace is deciding the best way to present dates and times to our users.
This sounds simple, but there’s quite a few considerations that we need to keep in mind.
Easily Readable by Humans
“Started 2 hours ago” and “Ends in 2 days” are much easier to understand than “Started Mon, 4 June 2007, 10:04am +1000″ and “Ends Wed, 6 June 2007, 9:28am +1000″.
Cachable by Search Engines
“Started 2 hours ago” or “Ends in 2 days” are meaningless when looking at a snippet or full copy of a page cached by a search engine 2 days ago. Likewise, “Started Mon, 4 June 2007, 10:04am +1000″ is difficult to understand for a person in a completely different time zone.
Cachable for Performance
We like to be able to allocate cache lifetimes to as many parts of our pages as possible. The text “Started Mon, 4 June 2007, 10:04am +1000″ needs no cache expiry, while “Started less than a minute ago” could only be reliably cached for 1 second.
While most people can figure out what “Started Mon, 4 June 2007, 10:04am GMT” means in their local time zone, it would be most valuable if we could do the sums for them, so they don’t need to spend 30 seconds figuring out that the auction ended… 1 second ago.
Because life wasn’t complicated enough already, tabbed browsing was invented so that we can force even more input into our heads at once. Tabs also makes it easy to get side tracked for hours before coming back to that SitePoint Marketplace listing. But currently there’s no way of knowing that the auction which says “Ends in 28 minutes” is actually long gone.
A Micro Solution
We start with some basic HTML markup:
<span class="sitepoint-datetime">Mon, 28 May 2007 01:30:49 GMT</span>
We’re looking forward to getting these and many other enhancements online over at the Design Contests and Marketplace.