You are here: Home / Dog Blog / Archives

Displaying Time

Thursday 4 December, 2003 ( 3:03PM GMT)

The issue of representing dates on the web has recently been raised by D. Keith Robinson and followed up by Simon Willison. But how would you represent a specific time?

The problem is that when you show the time, it's only going to be correct for one time zone, so it would actually be inaccurate in the other 23. This is, of course, due to the international nature of the web. If I make a comment on a web log at 5pm my time (that's in the London), it will actually be 12 noon in New York and 4am the next day in Sydney!

There is 'Coordinated Univeral Time' (UTC), which is based pretty much on Greenwich Mean Time, the time at zero-degrees longitude. But this time means pretty much nothing to most people outside of the UK, Portugal, The Gambia and other countries in that time zone. Just as Eastern Standard Time doesn't mean too much to people who don't share a time zone with the east of the USA. The times on the discussion forums in A List Apart, as one popular example don't make much sense on their own.

Most things we do in life are quite national so internationalisation is perhaps an easy thing to overlook. If you are going to display a time though, you should at least state from whose point of view that time is with a description such as 'GMT' or 'EST'.

Here's an idea - if you dynamically work out how long ago a certain event took place (like Simon Willison does on his web site) then you could minus that from the time on the clock of the users computer, which would give the correct time of that event from their point of view.

Comments

Comment 1

I like Hixie's solution: he states times in UTC in his source, and then uses JavaScript (bound via XBL, the reason for which I don't completely understand) to conver those times to the local time. In his CSS:

h3 [rel="bookmark"] {
width: 12em;
position: absolute;
left: -13.5em;
top: 0;
font-size: 0.75em;
text-transform: lowercase;
font-variant: small-caps;
text-align: right;
-moz-binding: url(/resources/bindings/timezone.xml#timezone);
}

The code is at http://ln.hixie.ch/resources/bindings/timezone.xml

So said Jan! on Thursday 4 December, 2003 at 3:27PM GMT.

Comment 2

Here is my problem with time : I keep getting phone calls from my friends and relatives (who are spread all over the world) at odd times. Do you have an easy code for showing my local time on my website (I have access to an Unix server hosted on the east coast, although I am on the west).
(actually your blog popped up on google while I was searching for that).

So said Tony on Friday 25 June, 2004 at 5:06AM GMT.

See Also

^ Top

SiteGround: Fast, reliable, recommended hosting.