0

How to convert the UTC time according to viewer's timezone?

I heard that it's not possible to get the timezone of the viewer, but then how do social networking services like FB, twitter do this ?

Edit: I have registered users on my application.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
Rajat Gupta
  • 25,853
  • 63
  • 179
  • 294
  • [Already there](http://stackoverflow.com/questions/338482/can-you-determine-timezone-from-request-variables) – sudmong Jul 22 '11 at 07:00
  • Social networking sites usually ask their customers about their location for their profiles; so later calculating their local time is trivial. – SJuan76 Jul 22 '11 at 07:04
  • @SJuan76: but users do travel internationally and they dont need to tell their timezone each time they login from some non-native timezone – Rajat Gupta Jul 22 '11 at 07:10
  • Use the machine local timezone. Anyway do not overwork, it is a website not a clock so if the time is not set to someone's standar is not that important. It is more important that items are kept in order than the actual time. – SJuan76 Jul 22 '11 at 07:29

1 Answers1

0
  • It is possible to get the user timezone, but this is done with javascript (get the detect_timezone.js). You most likely do that when users are registered.

  • Another, worse way is to approximate the timezone based on the IP

  • and finally (with combination of any of the above), you can give the user a choice to select his timezone in his settings

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140