- 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 08:44 AM
Hello,
I've linked you right to the documentation on setting the display value for a GlideDateTime object, please take a moment and use that link for example.
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 08:55 AM
Below is working
setDisplayValueInternal(String value)
CODE:
var gdt = new GlideDateTime();
gdt.setDisplayValueInternal("2022-04-29 15:54:26"); //uses current user session time zone (ITS)
gs.info(gdt.getValue());
Output:
2022-04-29 10:24:04
Thank you Allen and Robbie for you help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2022 09:06 AM
Hi Sandeep,
Glad you got to the desired solution. Some great help and advice from Allen and good to see leveraged the getValue() method I proposed.
To help others, can you mark my initial response as correct and/or helpful.
Thanks, Robbie