How do I get a user's date/time or timezone in

2019-02-17 22:20发布

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?).

1条回答
趁早两清
2楼-- · 2019-02-17 23:15

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".

查看更多
登录 后发表回答