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

Hey i am trying to parse data from portal into erp. I used Datetime-local in my html form and when i confirm the record from here it goes to database accurately. Its obvious because my psql shows timezone 'Asia/Karachi'. Its all good till that point but when i come inside erp and check that record it has additional 5+ hours. Y is it so? when my poostgres and odoo both share the same timezone then y i am getting these additional 5 hours?

Kindly help

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

Try the following code to convert the datetime before passing it to the database:

import pytz

check_time = fields.Datetime.to_datetime(check_time)
local_tz = self.env.user.tz // Timezone of the user
local_dt = pytz.timezone(local_tz)
local_dt = local_dt.localize(check_time, is_dst=None)
check_time = local_dt.astimezone(pytz.utc)

Pass check_time to the database and check the date in Odoo.

อวตาร
ละทิ้ง
ผู้เขียน

Thank you so much, its working now.

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 25
3563
1
ม.ค. 24
1628
2
ก.ค. 22
1391
0
ม.ค. 20
3712
0
พ.ค. 22
2038