By horita on
I'd like to know how can I post datetime field with timezone.
I'd like to post a content with datetime field by Rest API. I posted like this format, 2017-09-16T17:09:01. But in this way, the field is posted in UTC timezone. How can I post the field in local timezone?
I tried a format like this, 2017-09-16T17:09:01+0900. But an error was returned.
If anyone knows a solution, could you tell me the way?
Comments
I am facing the same issue.
I am facing the same issue. Did you manage to find a solution?
I'm sorry I can't find good
I'm sorry I can't find good solution for this problem. Therefore, I convert time from local timezone to UTC timezone before I post the content.
Having the same issue, this may have fixed it!
Im having this problem too!
I wonder if this could be a bug or something missing for Date fields on REST Api. However converting it to UTC was not my solution. It looks like when I POST any date to Drupal it does a calculation to make an adjustment from the local client location and may be not taking into acount the websites timezone.
I checked the websites and users timezone and they where both set to the Country where I am Guatemala which is GMT-6.
So I tried changing the Websites (not the users) default time zone to UTC, at /admin/config/regional/settings
So Im not sure if this is a bug or something missing on the date field REST Api, or im just not getting it!
but I guess whats going on is that the websites timezone needs to be set to UTC so at the moment of posting the date value to Drupal, the calculations are based entirely on the client local timezone since they are calculated taking the +00:00 timezone as a reference.
Can anybody explain this better, if this is an expected behavior?
Im not 100% sure if my solution of setting the website to UTC Timezone is the correct definitive one,
I havent tested it enough to be sure that its going to work globally but for now it makes sense to me that its going to work as long as the users timezone is correct, so I have to make sure all users in the site sets their personal time zone correctly.