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: 
TommyD2
Newbie

Convert time PDT (date string "2021-12-30T09:00:00-08:00" ) to UTC

I have a date string PDT "2021-12-30T09:00:00-08:00" and I want to convert it t date/time UTC. I have to try research on document Roku but it does not support it. I have to create the function with the idea 

 
' Convert time PDT to UTC
function convertPDTToUTC(dateStr as string) as string
  date = CreateObject("roDateTime")
  date.fromISO8601String(dateStr.Replace("[UTC]", ""))

  dateSC = date.AsSeconds()
  dateSC = dateSC + (7 * 60 * 60)

  datePDTToUTC = CreateObject("roDateTime")
  datePDTToUTC.FromSeconds(dateSC)

  return datePDTToUTC.ToISOString()
end function

but look it does not work right in all cases.
Any advice or ideas from you are greatly appreciated, thanks.

 
0 Kudos
1 REPLY 1
RokuJonathanD
Community Moderator
Community Moderator

Re: Convert time PDT (date string "2021-12-30T09:00:00-08:00" ) to UTC

Hi @TommyD2,

Have you tried using the roDateTime.FromISO8601String(dateString as String) as Void  function in your business logic?

 

0 Kudos
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.