views:

401

answers:

2

Hi, I've an issue while my data persisted as utc date-time and I want my users see the right time (thier) local time.

I can do this using javascript that sends the local time from the client machine to server, but this will cause me the first time the page will be seen it will be written using the UTC-Time.

do you have more ways? thanks.

A: 

Why not output UTC dates in tags, and then use javascript to convert them to local time once the page has loaded?

This kind of assumes your visitors have to use javascript, which is a bit naughty from an accessibility standpoint.

ninj
I am note whether this can change your decision but such way - will cause google-crawlers to see the original values (sometimes it can hurt your ranking)
rabashani
+1  A: 

Woot does this - Every time they render a forum post, they include a <span class="time">(The time in Central time, their home time)</span> and then have a javascript that enumerates all spans of class "time" and does a simple datetime conversion to convert it to the local time; if you don't have JS, you just get Central Time Zone times on forum posts.

Aric TenEyck
what is woot? is it an api or maybe website?
rabashani
Hey, I've checked the site but still not sure how they do this? what javascript they are using?!
rabashani