Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
68295 Visualizzazioni

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
Abbandona
Risposta migliore
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
Avatar
Abbandona

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

Risposta migliore

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
Abbandona

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

Risposta migliore

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
lug 25
2460
1
mag 25
2945
1
apr 25
2894
1
feb 25
2168
0
ott 24
1850