How to get separate date and time according to UTC format?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 01:43 AM
I need date and time in two different variables according to UTC . Any help how can I achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 03:28 AM
Try the solution which i provided .
Mark my Solution as Accept and helpful, if you find it helpful
Thanks,
Manjusha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 02:46 AM - edited 08-21-2023 02:48 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 01:51 AM
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.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 01:57 AM
Refer below link
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact
Thanks,
Manjusha Bangale