4

I'm using Lambda (Python) to develop a skill and I'm interested in giving the user some time-related information. On the request object there is a timestamp but that is UTC without offset. Is there a way to find the user's date/time or timezone without having to ask for location information (and if that's the only way, do you know of a database of US zip codes to timezone or another workaround?).

Josep Valls
  • 5,483
  • 2
  • 33
  • 67
  • 1
    This will help with the zip-to-timezone question: http://stackoverflow.com/questions/2456324/mapping-us-zip-code-to-time-zone – wblaschko May 19 '17 at 16:11
  • Zip code is really not a great way to set time zone. Especially if you want to handle customers outside the US. – Matt Johnson-Pint May 19 '17 at 17:48
  • @MattJohnson agreed, and I see how it will become a burden if I ever deploy to other regions (like the UK, but luckily, they have only one time zone there) but I don't see any other option for the time being. – Josep Valls May 20 '17 at 04:56
  • Don't know a whole lot about Alexa Skills, but if there's a way to get a zip code, is there also a way to get just a lat/lon or other location info? If so, there are APIs to translate lat/lon to time zone here: http://stackoverflow.com/a/16086964/634824 – Matt Johnson-Pint May 21 '17 at 00:05
  • @MattJohnson Thanks, currently there are only two options: Country+Zip OR Full street address. – Josep Valls May 21 '17 at 00:08
  • Perhaps try a geocoding API like Google's? You can then go after the time zone from there. https://developers.google.com/maps/documentation/geocoding/start – Matt Johnson-Pint May 21 '17 at 00:18
  • If anyone is interested in this, there is a feature request in the Amazon forums here: https://forums.developer.amazon.com/questions/8857/get-timezone.html#answer-76016 – Josep Valls Jul 19 '17 at 20:15

1 Answers1

0

It is now possible to get the user's timezone using the Alexa Settings API. See the related blogpost for official information about this feature's release.

The endpoint you'll be interested in is the following:

GET /v2/devices/{deviceId}/settings/System.timeZone

You simply need to provide the user's device ID, which is part of the received intent. The response will contain a timezone name, for instance "Europe/London".

Pyves
  • 6,333
  • 7
  • 41
  • 59