Convert Time into Zulu Format

Community Alums
Not applicable

Hi Team,

 

I want time in Zulu format, eg. 2022-05-31T07:34:45.968Z.

 

Can you please tell me if there's a function to implement it?

 

Thanks and Regards,

Hrithik Nirupam

 

 

7 REPLIES 7

Community Alums
Not applicable

 Hi @Community Alums ,

Can you please try below code 

var gdt = new GlideDateTime();
gdt.setTimeZone('Zulu');
gs.print(gdt);

This gives you time in Zulu time zone

 

Please feel free to ask any query 

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak

Hayo Lubbers
Kilo Sage

Hi @Community Alums ,

 

Not sure in the GDT. The suggestion by @Community Alums delivers you the date/time without the T/Z and milliseconds.

You might consider using the plain javascript Date function instead of the GlideDateTime options:

var d = new Date();
gs.info(d.toISOString());

 

Community Alums
Not applicable

Hi @Hayo Lubbers ,

 

This script won't work in ServiceNow.

 

Thanks and Regards,

Hrithik.

Hi @Community Alums ,

 

In which place wouldn't it work? Running it as background script works fine.

 

Creating a script include and calling it (from business rule and background script) works fine:

Script IncludeScript Include

As background script

Background ScriptBackground Script

As display business rule

Business RuleBusiness Rule

DisplayDisplay