I managed to get date by
import datetime
getDate = datetime.date.today()
print(getDate.strftime("%Y-%B-%d"))
Output is 2018-June-23
But I want to format output like this: 2018-JUNE-23 (month is uppercase)
To do this directly in the format string, prepend a carrot on the month (^):
>>> getDate = datetime.date.today()
>>> print(getDate.strftime("%Y-%^B-%d"))
2018-JUNE-22
Note: This works if you have the glibc extensions (or equivalent features) available on your platform strftime. You can check for that by calling man strftime. If it's not working on your platform, or you need to guarantee the behaviour cross-platform, then prefer to just make an extra function call here by using str.upper as shown in the other answer.
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