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

how can I add ukrainian language to this datetime?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • and connect the package to the main program, in which the user selects the language in which he wants to get the value of the current date. – Masha Ignatenko Apr 08 '19 at 23:49
  • 1
    Possible duplicate of [Python: date formatted with %x (locale) is not as expected](https://stackoverflow.com/questions/3438120/python-date-formatted-with-x-locale-is-not-as-expected) – Life is complex Apr 08 '19 at 23:53

1 Answers1

2

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 - понеділок'
elethan
  • 16,408
  • 8
  • 64
  • 87