User variable GMT conversion

claystroup
Tera Guru

I collect a 'requested for' date/time on my REQ form. When I write the value to the TASK, it displays in GMT. I understand that using the calendar picker on the form stores the date/time in GMT, not the user timezone, but how can I get the variable output in a workflow to convert back to user time zone without having to do a bunch of flippy floppy gobbildy gookey... err, what seems like erroneous code for such an operation. I cannot find anywhere on google where there's a '<variable>.datetime' attribute in the same idea as a <variable>.name displays the literal name entered into the form field.

Here is my workflow script;

task.short_description = current.short_description + " for " + current.request.requested_for.name;

task.description = "Add Nxlog Agent to:"

+ "\nDevice Name: " + current.variable_pool.eh_machine_name.name

+ "\nOS Version: " + current.variable_pool.eh_machine_os_version

+ "\nMachine IP: " + current.variable_pool.eh_machine_ip

+ "\nServer Function: " + current.variable_pool.eh_ina_server_func

+ "\nContact Name: " + current.variable_pool.eh_ina_contact_name.name

+ "\nRequested Install Date: " + current.variable_pool.eh_ina_req_inst_date

+ "\nNotes: " + current.variable_pool.eh_ina_notes

+ "\nAdditional Contact Info: " + current.variable_pool.additional_info;

I am trying to get the current.variable_pool.eh_ina_req_inst_date to display in est, not gmt.

2 REPLIES 2

prasad48
Tera Guru

It may use full



  getDateFromFormat(g_form.getValue('the_date_field'), g_user_date_format);


                   


(g_user_date_format — predefined variable which gets user specific date format)


(getDateFromFormat — method which converts to the specified date format)



g_user_date_time_format — can also be used to get user's datetime format.



Helpful link - https://www.servicenowguru.com/scripting/client-scripts-scripting/client-side-dates-in-servicenow/


Thank you Prasad!



We actually ended up deciding that due to the nature of the request, it wasn't really appropriate for the requester to enter a time, only a date, and the system doesn't modify the date. But I appreciate this response should I need to convert the date/time in the future.