Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format date with month name in polish, in python

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:

6 września 2010

and not:

>>> datetime.today().date().strftime("%d %B %Y")
'06 wrzesień 2010'
like image 495
Janusz Skonieczny Avatar asked Dec 13 '22 19:12

Janusz Skonieczny


1 Answers

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.

like image 59
Vinay Sajip Avatar answered Jan 06 '23 06:01

Vinay Sajip