Search code examples
pythonodoodatetime-format

How can I format date in Odoo 15 QWeb report? i want to format specific date format not the


How can I format date in Odoo 15 Account Pay check form? for not using the actual date and not changing into the language date format? please help.

context_timestamp(datetime.datetime.now()).strftime('%m-%d-%Y')

Solution

  • You can force specify date format using t-options, if you have date field, like:

    <span
        t-field="o.my_date_field"
        t-options="{'format': 'dd.MM.YYYY'}"
    />
    

    If you are generating current time, without actual field, you can simply do like:

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