What is the quick way to format date in python using only .format method? I know there is a way to do it without using strftime. I need more elegant me
.format
strftime
I know a good method which is not widely known, but very useful.
Here is how you can do it:
from datetime import datetime '{:%Y-%m-%d %H:%M}'.format(datetime(2018, 12, 28, 10, 30))
The output is 2018-12-28 10:30
2018-12-28 10:30