How can I get the month name from the month number?
For instance, if I have 3, I want to return march
3
march
date.tm_month()
How to get the string march?
import datetime mydate = datetime.datetime.now() mydate.strftime("%B")
Returns: December
Some more info on the Python doc website
[EDIT : great comment from @GiriB] You can also use %b which returns the short notation for month name.
%b
mydate.strftime("%b")
For the example above, it would return Dec.
Dec
2.1m questions
2.1m answers
60 comments
57.0k users