Format date with month name in polish, in python

后端 未结 3 1317
迷失自我
迷失自我 2021-01-14 01:24

Is there an out of the box way to format in python (or within django templates), a date with full month name in accordance to polish language rules?

I want to get:

3条回答
  •  执念已碎
    2021-01-14 01:35

    Use Babel:

    >>> import babel.dates
    >>> import datetime
    >>> now = datetime.datetime.now()
    >>> print(babel.dates.format_date(now, 'd MMMM yyyy', locale='pl_PL'))
    6 września 2010
    

    Update: Incorporated Nathan Davis' comment.

提交回复
热议问题