İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
67676 Görünümler

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')"/>

Avatar
Vazgeç
En İyi Yanıt
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
Avatar
Vazgeç

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

En İyi Yanıt

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 

Avatar
Vazgeç

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

En İyi Yanıt

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Tem 25
1817
1
May 25
1900
1
Nis 25
2358
1
Şub 25
1657
0
Eki 24
1433