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

how can I get the current date with the correct timezone of the user printing the report?

I am using this, but this brings the current UTC time.
<span t-esc="time.strftime('%Y-%m-%d %H:%M:%S')"/>

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
อวตาร
ละทิ้ง

This should be the correct answer

This is the correct answer

context_timestamp().strftime('%Y-%m-%d %H:%M') gives 'NoneType' object is not callable
error in odoo 14 with dt.dt.now() or with a datetime field or without parameter :(

Thanks a lot brother, this is the best answer

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

I have just created a module which allows you do to:

<span t-usertime="%Y-%m-%d %H-%M-%S" /> 

and get the correct timezone. See it on GitHub 

อวตาร
ละทิ้ง

This has now been accepted in the OCA addons. Updated the github link.

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

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 25
1811
1
พ.ค. 25
1896
QWeb: use t-if to check birthday date แก้ไขแล้ว
1
เม.ย. 25
2354
1
ก.พ. 25
1652
0
ต.ค. 24
1433