Convert Date Time to UTC

sandeep24
Tera Guru

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

1 ACCEPTED SOLUTION

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!

View solution in original post

12 REPLIES 12

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!

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.

Sample code or JS method please...

 

Thanks

Hi Sandeep, Did you see my response? The first response to your question and using the 'getValue' method?

Thanks, Robbie

To help others, please mark correct and/or helpful.

Yes I did try below

Passed start date to Glide Ajax(ex: "2022-04-29 08:00:00", this is in IST)

and in SI, i used below

var gdt = new GlideDateTime(startdate);
gs.print(gdt.getValue());

 

I return i am getting "2022-04-29 08:00:00"(same time, but i need in UTC)

Hi,

I appreciate you replying in my thread chain down here, but there is more to this than what you've posted above hence why I'm spending the time to reply down here.

We aren't necessarily saying the same thing.

Your response covers the very last step of a multi-step process.

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!