How to print date in readable format

We are using object data type for date input. If I print that variable value it shows ‘Object Object’. How can I convert it into readable DD/MM/YYYY or MM/DD/YYYY format ?

Workaround Adopted : We saved the object variable into string variable using modifier node and then again used modifier node to trim the format. I am sure there would be a better and right way of displaying the dates in bot.

Below is the format of the date after the dates(in object) is modified into dates(in string) :

{“value”:{“timestamp”:“Tue, 11 Jan 2022 00:00:00 GMT”,“year”:2022,“month”:1,“date”:11,“day”:“Tuesday”,“hour”:0,“minute”:0},“range”:{“exists”:false}}

We even used {{{variables.vleaveenddate.date}}} OR {{{variables.vleaveenddate.year}}} but it did not return any value. vleaveenddate is a variable with object data type, note all this is used in text node.

1 Like

Yes @Pranav

You can refer to this doc to learn about how to access response from date prompt: https://docs.yellow.ai/docs/platform_concepts/studio/steps/prompts-and-messages#date-prompt.

You can also refer to this screenshot below to print the date in DD/MM/YYYY format:

Syntax to access the date prompt response: {{{variables.variable_name.value.date}}}

It will be displayed like this in the bot:

Hope this helps!

1 Like

Thanks @Pratik this solution worked !! Changed the format as suggested above and it is showing as expected. Thanks !!

1 Like