Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Binge Watcher

How to convert a string to date.

Hi guys, I am trying to convert a string to Date but cannot find a solution. so that is why i need your help.
I am getting date from api response as follows,

but i am unable to change it to Date, i want to sort an array on basis of Date so that is why i am doing this if anyone can help me to sort an assoc Array without changing it to date that will be more helpful,
Thanks in advance.
0 Kudos
Binge Watcher

Re: How to convert a string to date.

' You can't sort an associative array. Values are accessed via their keys
' To convert a string to a Date object:
date = CreateObject("roDateTime") ' creates date object with current date
print(date.AsDateString("long-date")) ' prints Saturday August 6, 2022
dateString = "2022-03-08 00:00:00.000" ' string must be in ISO8601 format
print(date.AsDateString("long-date")) ' prints Tuesday March 8, 2022