Help

5

Current Date in QWEB Report with user timezone

Avatar
Felipe

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

1 Comment
Avatar
Discard
Avatar
Sehrish
-
2 Answers
9
Avatar
Vince Vinet
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 

1 Comment
Avatar
Discard
Avatar
Vince Vinet
-

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

19
Avatar
陈帆
Best Answer
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
1 Comment
Avatar
Discard
Avatar
Andre de Kock
-

This should be the correct answer