I want to know the client script to get the UTC time from the "Date/Time" field

bonsai
Mega Sage

When I executed "g_form.getValue(field name)", I got the local time set in the field.

I want to get it as UTC time, not local time.
What should I do?

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @bonsai 

If you're passing the date time value to the Server side, you can use this API below

setDisplayValue(String asDisplayed)

Sample.
Timi_0-1703562678514.png
Timi_1-1703562682005.png

 

In the other hand, you can leverage the Date object in client side.

Sample

 

new Date('2023-12-28 10:40:29').toUTCString();

 

 

Cheers,
Tai Vu

View solution in original post

1 REPLY 1

Tai Vu
Kilo Patron
Kilo Patron

Hi @bonsai 

If you're passing the date time value to the Server side, you can use this API below

setDisplayValue(String asDisplayed)

Sample.
Timi_0-1703562678514.png
Timi_1-1703562682005.png

 

In the other hand, you can leverage the Date object in client side.

Sample

 

new Date('2023-12-28 10:40:29').toUTCString();

 

 

Cheers,
Tai Vu