Search code examples
python-3.xodoo-11

Print current date in English language


In Odoo, I'd like to print current date in English in QWeb report:

<span t-esc="datetime.datetime.now().strftime('%d %B %Y')"/>

The expected behavior is : 20 January 2019

The current behavior is: 20 janvier 2019

What should I do to display the month in English instead of the system language (French)?


Solution

  • try using LOCALE

    import locale 
    
    locale.setlocale(locale.LC_ALL, 'en_US')
    
    print(datetime.datetime.now().strftime('%d %B %Y'))