Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
11749 มุมมอง

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?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello,

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).

คำตอบที่ดีที่สุด

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;

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
มิ.ย. 25
1011
1
ก.ค. 23
3706
4
ธ.ค. 22
9653
2
เม.ย. 21
3713
1
ต.ค. 18
5073