Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datetime change language from english to ukrainian python?

import datetime
print(datetime.datetime.today().strftime("%d.%B.%Y - %A - %X" ))

how can I add ukrainian language to this datetime?

like image 735
Masha Ignatenko Avatar asked Oct 27 '25 05:10

Masha Ignatenko


1 Answers

You could use Babel's date module (after pip installing it):

>>> from babel.dates import format_datetime
>>> import datetime
>>> format_datetime(datetime.datetime.today(), locale='uk_UA')
'8 квіт. 2019 р., 20:23:32'

Does this give you what you want?

You can also use Babel's pattern syntax to format the date string, but I am not familiar with Ukrainian date formatting some I am not sure if this formatting is correct:

>>> format_datetime(datetime.datetime.today(), "d.MMMM.Y - EEEE", locale='uk_UA')
'8.квітня.2019 - понеділок'
like image 66
elethan Avatar answered Oct 29 '25 20:10

elethan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!