Convert From any timezone to UTC

vps
Tera Contributor

How to convert time from any timezone to UTC?

I have a catalog form with the date, time, and timezone field. When any user submits the form, we need to email the time in UTC format

find_real_file.png

7 REPLIES 7

From the field names, it seems to be a resignation submission form. The form seems like it is used to enter a date/time when an email will be sent to a resigning employee.

If the form is going to be submitted by the end user, ServiceNow will automatically convert the date/time based on user's timezone to the UTC. In this case, there's no need to do explicit conversion.

If the form is going to be submitted by somebody else like somebody in personnel, that person can convert the time to UTC and enter the date/time as a string. Of course, this will waste that's personnel employee's time especially when there are many people resigning at the same time. To make ServiceNow convert the date/time, it would require a list or a table of timezone and their offset from UTC.

FYI, employee's timezone is available in User table (sys_user) so a field isn't actually required. Employee's timezone can just be found from the User table.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Allen has already mentioned the approach.

Can you share what approach/script you are using which is not working?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Vaishnavi Lathk
Mega Sage
Mega Sage

Hi,

If you define a column with the type of "Date", the system will stores value only in UTC. While displaying the value will get converted from UTC to User timezone. If you want to display the value in UTC irrespective of User Timezone, define the column with the type of "String" and store the value in UTC. The String type values will not get converted. It will get displayed as it is.

Use this command to get the current time in UTC

gs.nowNoTZ()

Refer following thread:-

https://community.servicenow.com/community?id=community_question&sys_id=72998ba5db5cdbc01dcaf3231f96199b

Regards,

Vaishnavi