Skip to Content
Menu
This question has been flagged
3 Replies
66842 Views

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

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 :(

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 

Avatar
Discard

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

Best Answer

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

Avatar
Discard
Related Posts Replies Views Activity
1
May 25
643
1
Apr 25
1777
1
Feb 25
962
0
Apr 25
959
0
Oct 24
747