Afsar Ahamad
Afsar Ahamad

Reputation: 1997

How to convert date (YYYY-MM-DD) to today/tomorrow etc in Alexa custom skill?

I know about AMAZON.DATE Built-in Slot Types which can convert today/tomorrow to date in format YYYY-MM-DD. When a user speak today/tomorrow then alexa converts it to date but I want alexa to speak today/tomorrow based on the date. I have an object of string contains yyyy-mm-dd hh:mm I want alexa to speak date & time in the form defined in AMAZON.DATE. I seen Speech Synthesis Markup Language (SSML) but did not get any reference to convert date to such words like defined in AMAZON.DATE.

Thanks.

Upvotes: 0

Views: 395

Answers (1)

Greg Bulmash
Greg Bulmash

Reputation: 1957

That conversion for output is something you do in your code. Any formatting of how the date is spoken on output is up to your code to do. If you're using JavaScript, the moment library can be useful. If you want to keep your code tight and memory usage low, read up on the Date object.

For a little help in doing it correctly, check out the last section of the beginner Cake Time tutorial, which explains how to get the time zone of the device, so your date math is accurate.

Upvotes: 2

Related Questions