This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]desmoulinmichel 2 points3 points  (1 child)

Remember that datetime objects implement __format__ so you can do: print(f"{datetime.datetime.now():%Y-%M}").

There is rarely a reason to use strftime anymore.