Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
67848 Vistas

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

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

Mejor respuesta

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
Descartar

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

Mejor respuesta

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
jul 25
1958
1
may 25
2042
1
abr 25
2476
1
feb 25
1748
0
oct 24
1492