Debian is set to en_US
but I need day/month in German.
So how can I get %a
to output Do
instead of Thu
?
draw.text((0,34), time.strftime("%a %d.%m.%Y"), font=font)
Get Month Name from Date in Python To get the month name from a number in Python, the easiest way is with strftime() and passing "%M". You can also use the calendar module.
The user gives the input for the month number. datetime.strptime () is called. It takes month number and month format "%m" as arguments. Passing "%b" to strftime returns abbreviated month name while using "%B" returns full month name. This method imports calender module. It simply uses a for loop to iterate over the number of months (12).
In Python, we can work on Date functions by importing a built-in module datetime available in Python. We have date objects to work with dates. This datetime module contains dates in the form of year, month, day, hour, minute, second, and microsecond. Let us discuss different ways to convert a month number to a month name.
SQL developers can use following T-SQL statements including "Set Language" for setting a specific language which the day and month names will be automatically translated into. SQL DateName datetime function is used to return text descriptions of months or week days in SQL Server database development.
Linux
>>> import datetime
>>> import locale
>>> locale.setlocale(locale.LC_TIME, 'de_DE.UTF-8')
'de_DE.UTF-8'
>>> d = datetime.datetime.now()
>>> d.strftime("%a %d.%m.%Y")
'Do 24.05.2018'
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With