How to get separate date and time according to UTC format?

Akki1
Tera Contributor

I need date and time in two different variables according to UTC . Any help how can I achieve this?

8 REPLIES 8

@Akki1 

 

Try the solution which i provided .

 

 Mark my Solution as Accept and helpful, if you find it helpful

 

Thanks,

Manjusha

 

Hello @Akki1 

 

In that case use " " // blank space for spliting.

 

 

 

var datetime = gdt.split(' ');
var date=datetime[0];
var time=datetime[1];
gs.info(date);  //2023-8-20
gs.info(time); // 15:12:60

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello @Akki1 ,

You don't need to covert any time as UTC is the system backend time zone.

So all you need to do is use something like:

var date1 = current.getValue('date_time_field');

And now date1 has the date/time in UTC format. If you want to then display this in those custom fields, if that's important to you, then you can use:

current.u_utc_field = current.getValue('date_time_field');

Replace the field names above as necessary. The examples above would be use in "before" Business rule.

 

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

manjusha_
Kilo Sage

@Akki1 

 

Refer below link 

 

https://www.servicenow.com/community/developer-forum/glidedatetime-get-hours-minutes-and-seconds/m-p...

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact

 

Thanks,

Manjusha Bangale