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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
uj24153
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,

03/08/2022
 
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
1 REPLY 1
thomasferraro
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
date.FromISO8601String(dateString)
print(date.AsDateString("long-date")) ' prints Tuesday March 8, 2022
 
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.