How to set value in glide_date_time field?

jackh
Kilo Contributor

Hi,

I'm calling ServiceNow REST API to create change request record.   But I'm not able to set the Start Date and End Date fields correctly when setting them as date string, e.g. "2016-09-05 20:00:00".   The result on change record shows "2016-09-05 14:00:00" (don't know where such value is coming from).   I notice these are glide_date_time field.   How to set such field via REST API?

Thanks

1 ACCEPTED SOLUTION

Geoffrey2
ServiceNow Employee
ServiceNow Employee

It's probably a timezone issue you're seeing. The value might be getting saved as "2016-09-05 20:00:00" in UTC, but then displaying it as "2016-09-05 14:00:00" in your timezone, or the system's timezone.   Check what the value is being saved as in the database by using View XML from the form.


Take a look at http://wiki.servicenow.com/?title=GlideDateTime. You might need to use GlideDateTime with setDisplayValue to get the result you want.


View solution in original post

3 REPLIES 3

Geoffrey2
ServiceNow Employee
ServiceNow Employee

It's probably a timezone issue you're seeing. The value might be getting saved as "2016-09-05 20:00:00" in UTC, but then displaying it as "2016-09-05 14:00:00" in your timezone, or the system's timezone.   Check what the value is being saved as in the database by using View XML from the form.


Take a look at http://wiki.servicenow.com/?title=GlideDateTime. You might need to use GlideDateTime with setDisplayValue to get the result you want.


jackh
Kilo Contributor

It was timezone issue.   Really appreciate your answer.


HI Jack,



Can you please tell me how you handle the data issue?


I am having same issue not able to populate correct date in my date time field.



Thanks,


Santosh