+2 votes
330 views

I made some custom datetime fields that display the time as saved in the database table. Even if my user has a different tz it will display as show in the database. Since the time was showing as my current tz i just left it as it is. This is one issue since odoo wasn't rendering the correct time.

I found this issue after i changed the server timezone (which is ET). After i updated the time, my custom fields were displaying the wrong time and i didn't find a way back so i had to save this data transformed. 

There's a place in odoo where you save those fields timezone. If you know where they are let me know

Also this should be in the documentation, I mean the issue about setting up your timezone before creating custom fields. 

in Back-end by (10.5k points) | 330 views

1 Answer

+3 votes

Hi,

Not sure what exactly your issue is about. Suppose if you are here in India, your user timezone will be Asia/Kolkata , ie, +5:30 UTC. And if you save a date-time value 26/06/2019 6:30 PM in your custom field, in the database it will get stored in the UTC as 26/06/2019 1:00 PM(by subtracting the +5:30 from the time).

And when the same field has to be displayed in the front end from the database, the UTC time from the database is taken and displayed according to the users timezone. So when displaying the same field to the user with the timezone as Asia/Kolkata it will be 26/06/2019 6:30 PM, and for another user with timezone Saudi Arabia which is +3 , the value will be 26/06/2019 1:00 pm + 3 hours, ie 26/06/2019 4:00 PM.

In the database 26/06/2019 1:00 PM,

for user 1 with timezone +5:30 , time will be 26/06/2019 06:30 pm.

for user2 with timezone +3:00, time will be 26/06/2019 04:00 pm.

Thanks

by (8.8k points)
205 questions
180 answers
37 comments
221,390 users