Odoo Help


Datetime issue, not UTC time

on 2/16/16, 3:32 AM 2,009 views

I am developing odoo8 in a windows pc with eclipse and pydev.

My problem is datetime generated with fileds.Datetime.now() is local time (not UTC time).

Also, relevant field data in PostgreSQL database is local format (but reserved fields in database like create_date and write_date are in UTC format)

This makes datetime fields showing in UI wrong.

What is the root cause?


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--

| 3 3 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 2/16/16, 3:41 AM


The idea is to always stock date in utc in database.

And display it in the timezone of the current user...

So in the ui, you will see the date from db + the lambda of your timezone.

You are right, and i am aware of that. My problem is that I get date in database in local time format, NOT a naive UTC time. For example, i have a Datetime field, and the local time in China now is 22:00. After i write this field to fields.Datetime.now() programmatically, I get 22:00 in the database, NOT 14:00 . Another weird thing is, write_date field of this record is 14:00 (RIGHT UTC time, and create_date field will always be correct).

on 2/16/16, 8:57 AM
Mai Ecarde
On 8/3/16, 5:47 AM

Check if the user's timezone is set to UTC? settings -> users -> [user] -> preferences (tab)

Check if the postgres database timezone is correct:

SELECT current_setting('TIMEZONE') TZ;

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/16/16, 3:32 AM
Seen: 2009 times
Last updated: 8/3/16, 5:47 AM