- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2022 06:35 AM
Hi,
ON NEW FORM when user selects DATETIME field(ex: start date), I need to convert it to UTC time in Client Script(or using GlideAjax)
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2022 07:58 AM
Hi,
Perhaps it's doing that because it's not saved to the database at that time. I see why you were specifically mentioning "new" record in your post. I didn't see that before.
With that said, you should be able to still use GlideAjax, onChange client script, for example, take that value from that field, send it to your script include and use that to "set the display value" of a GlideDateTime object, so not set the value, but set the display value of a GlideDateTime object.
Then...get the value, send it back to your client for use in your alert or whatever you need to do.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2022 07:39 AM
Hi Sandeep,
Can you expand on the requirement and why you need to 'convert' this to UTC? The reason I ask is because all times are stored in UTC and appear globally based on the system time zone.
Additionally you will find however that users will be presented with that time based on their local time zone, according to their user preference settings. (Eg UK - GMT or US - PST).
See - https://docs.servicenow.com/en-US/bundle/sandiego-platform-administration/page/administer/time/reference/r_TimeZones.html
To answer your question specifically (with no context),you can use getValue() on GlideDateTime() to get value in UTC as below.
To help others, please mark correct and/or helpful.
Thanks,
Robbie
https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server_legacy/c_GlideDateTimeAPI#r_GDT-getValue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2022 07:50 AM
Hi Robbie,
Thank you for your time,
Requirement is to alert schedule based on Start Date on NEW CHNAGE Form.
when I use alert(g_form.getValue('start_date')); it is displaying datetime in USER Timezone,
But i want in UTC Time Zone.
For OLD records, i can use GLideAjax and then user glidequery on change record and then change.getValue('start_date')
I want same functionality for NEW record also.
so need help to convert user time zone(ex: IST/US Pacific/Israel) to UTC in client script/ajax on NEW FORM
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2022 07:40 AM
Hello,
If you "get the value" of the date/time field...it's already in UTC format (as the server value time is UTC).
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2022 07:51 AM
Hi Allen,
Thank you for your time,
Requirement is to alert schedule based on Start Date on NEW CHNAGE Form.
when I use alert(g_form.getValue('start_date')); it is displaying datetime in USER Timezone,
But i want in UTC Time Zone.
For OLD records, i can use GLideAjax and then user glidequery on change record and then change.getValue('start_date')
I want same functionality for NEW record also.
so need help to convert user time zone(ex: IST/US Pacific/Israel) to UTC in client script/ajax on NEW FORM
Thanks,