question

EricS avatar image
EricS asked

Alexa Intent Date slot vs backend UTC date

There are many questions similar to this but I have not found an answer. I have a skill that references a calendar. When an intent with a {date} slot is received, the date appears to be in UTC rather than the user's local time, so "today" can be off by several hours. I saw a post that said it was an issue with the simulator, but I get the same behavior with the deployed skill. It seems reasonable that Alexa would use the local timezone when references are made by a user to dates or times. Anyone have a resolution for this? TIA.

alexaslots
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Rokas avatar image
Rokas answered

If you have UTC time when skill was invoked, you could get user device timezone (docs) and then count the time according to it. This will require some extra code, but this way you'll get the exact user time.

If you are using js I recommend to use moment js package which makes life so much easier when working with time.

Also, if you are using alexa-sdk-v2 for node, then you don't need to do an api call to get user timezone, you can do it by using built in method 'getSystemTimeZone'. Also I have built an example: here, if documentation doesn't help.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.