Convert date from CST to UTC

Gurushant2
Mega Contributor

Hi, Guys there,

I need help in the Conversion of dates from CST to UTC. Tried couple of ways, but seems unreliable.

Can anyone help me the way to get CST date into UTC format ?

 

Below is the example and solution looking for,

var cstDate = "2020-07-24 09:10:00"; //CST time 9:10 AM.

var gdt = new GlideDateTime(cstDate);

gs.debug(gdt); //it prints 2020-07-24 09:10:00.

---------------------------------------------

Imagine CST to UTC has 6 hrs difference (may vary, sometimes 5, sometimes 6).

Imagine UTC to IST has 5.30 hrs difference (may vary).

Seeking for a solution which will return,

  • '2020-07-24 15:10:00' if I am in UTC Timezone.
  • '2020-07-24 20:40:00' if I am in IST Timezone.

In simple based on my current timezone.

 

PN: I am trying to get the solution being in the Scoped app.

8 REPLIES 8

Hi,

I don't see any other method as of now.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Check this page

https://snprotips.com/blog/2017/9/12/handling-timezones-in-servicenow-timezoneutil

-Anurag

-Anurag

Hi,

Just checking to see if this is answered or not?

-Anurag

-Anurag

Hi Anurag,

Thanks for the suggestion.

But, It could not resolve my issue, as I am trying to get the solution in Scoped App.

I cannot load timezone packages being in the Scoped app (I cannot make any changes to global scope).

 

Any other workaround I can get please.