Use strftime : >>> from datetime import datetime >>> datetime.today().strftime('%Y-%m-%d') '2021-01-26'. To also include a zero-padded Hour:Minute:Second at ... ... <看更多>
In this blog, I'll talk about how to convert datetime to string and inverse, with following date format: YYYY-MM-DD; YY-MM-DD; MM-DD-YYYY; MM-DD ... ... <看更多>