Formatting “yesterday's” date in python

后端 未结 6 2107
难免孤独
难免孤独 2020-12-02 03:56

I need to find \"yesterday\'s\" date in this format MMDDYY in Python.

So for instance, today\'s date would be represented like this: 111009

I ca

6条回答
  •  自闭症患者
    2020-12-02 04:54

    Could I just make this somewhat more international and format the date according to the international standard and not in the weird month-day-year, that is common in the US?

    from datetime import datetime, timedelta
    
    yesterday = datetime.now() - timedelta(days=1)
    yesterday.strftime('%Y-%m-%d')
    

提交回复
热议问题