2

We can find some lists of the UTC time offsets, showing the difference in hours and minutes from Coordinated Universal Time (UTC), from the westernmost (−12:00) to the easternmost (+14:00).

In general, we save datetime using iso8601 format.

However - by default - we just includes some countries and regions. And it is not very accurate. For instance, UTC+01:00 is for Paris, Rome, Stockholm, Tunis, even if those cities are not exactly on the same longitude...

I would like to be able to find the true UTC time offset from a geolocation, in order to have a local time based on the position of the sun in the sky.

I mean, instead of having UTC+01:00 near the Eiffel Tower at the geolocation 48.858844300000001,2.2943506 I would prefer to have UTC+01:13 for example.

How could we do, having a geolocation such as 48.352845300000001,40.9943506, to get the true UTC time offset?

Thank you for any ideas.

Zag zag..
  • 6,041
  • 6
  • 27
  • 36
  • What purpose would this serve? Local time doesn't really work that way. Have you read [the timezone tag wiki](http://stackoverflow.com/tags/timezone/info)? You might also be interested in [how to convert a geolocation to the proper IANA time zone](http://stackoverflow.com/q/16086962/634824). – Matt Johnson-Pint Dec 31 '13 at 16:20
  • I want to have offsets that are 8-minute offset, for instance. More precise than time zones. – Zag zag.. Dec 31 '13 at 23:34
  • Sure, as long as you understand that people don't actually set their clocks that way anywhere in the world. At least not in modern times. – Matt Johnson-Pint Dec 31 '13 at 23:52
  • This is tres-cool, but the idea doesn't map very well to the idea of a UTC offset. In particular, due of the [Analemma](http://en.wikipedia.org/wiki/Analemma), the offset changes throughout the year at a single location. I think you would want to use something like [Local Mean Time](http://en.wikipedia.org/wiki/Local_mean_time) which is fixed for a given Longitude. – Benjohn Mar 24 '14 at 13:01
  • You should be able to derive local mean time as a UTC offset from Longitude (which is relative to Greenwich) fairly easily. It's: `localOffset = (location.longitude * 24.0 / 360.0)`. I think :-) You might need to do a sign change! – Benjohn Mar 24 '14 at 13:08

1 Answers1

1

I've never heard of the phrase 'true UTC', but I understand what you are asking. You could calculate the longitude distance between the user's position and the closest UTC longitude line, and then use that to determine your fractional hour offset.

Andrew - OpenGeoCode
  • 2,299
  • 18
  • 15
  • This is also the way I would do it. However should we use a range from -12 to +12 (because there's 24h in a day) or a more complicated range from -12 to +14? Personally I would go for the first way. What do you think? – Zag zag.. Dec 28 '13 at 23:14
  • Each hour is 15 degrees in longitude apart (360/24). 0 degree longitude (prime meridian) would be UTC+00:00. 15 degrees East would be UTC+01:00 and 15 degrees West would be UTC-01:00. I googled the coordinate centroid for Berlin, Germany. The longitude is 13.3833 degrees East. This would calculate to UTC+00:54. I believe what you are asking about maybe what is called solar time. – Andrew - OpenGeoCode Dec 29 '13 at 00:59