REST API, date/time fields, and time zones

vaylortrucks
Kilo Contributor

We are using the table REST API to add records to a table. These records include a "Due Date" field. For each entry, the data entered into the "Due Date" field is a date with no time, for example "2017-5-5" as a string, or 2017-05-05T04:00:00Z as a date/time. However, when you browse the newly created record in ServiceNow, the date and time given are 4 hours behind, (2017-05-04 20:00:00 in this example).

Because the difference in time (4 hours) coincides with our current time zone, it seems likely that a time zone setting is the problem. I have tried changing the settings for the ServiceNow account being used to make the connection; setting the time zone to GMT, and also to the local time zone (US / Eastern), but neither had an effect on the outcome. We have also set the default date format for that account to yyyy-MM-dd with no change in the outcome.

1 ACCEPTED SOLUTION

ashwinkumar_pat
Giga Expert

He Vaylor,



if the the user's timezone is not set, then the system time zone is used as per the time zone documentation (servicenow docs)



I tested this use case and here is what happened with me.



I created a record in my test table which stores the birth date and time. I passed birth date and time as 1978-10-22 09:15:00. The user which executed this REST API call is in Central time zone. The system stored the birth date as 1978-10-22 04:15:00 i.e. exactly 5 hours behind. That is in UTC time zone.



I changed the user's time zone to Eastern time zone and the system now stored the date 4 hours behind.



However, my system time zone is set to IST.



So to conclude, the REST API stores the date/time in UTC time zone.



~@$#


View solution in original post

3 REPLIES 3

ashwinkumar_pat
Giga Expert

He Vaylor,



if the the user's timezone is not set, then the system time zone is used as per the time zone documentation (servicenow docs)



I tested this use case and here is what happened with me.



I created a record in my test table which stores the birth date and time. I passed birth date and time as 1978-10-22 09:15:00. The user which executed this REST API call is in Central time zone. The system stored the birth date as 1978-10-22 04:15:00 i.e. exactly 5 hours behind. That is in UTC time zone.



I changed the user's time zone to Eastern time zone and the system now stored the date 4 hours behind.



However, my system time zone is set to IST.



So to conclude, the REST API stores the date/time in UTC time zone.



~@$#


If I've answered your question, please mark the response as helpful and correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   Please review How to Mark Answers Correct From Inbox View.


Hi Ashwin,



We are trying to set the 'due_date' field for the request (sc_request) using a the rest api, it will not set it some how, i have set up the time zone for the user record (we used to submit the api request), even then..



What do you think the issues is?



Thanks


Yogish Dafedar