Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
TommyD2
Level 7

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
Roku Employee
Roku Employee

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