code-dumps/py/dates-test.py

6 lines
200 B
Python
Raw Normal View History

2024-03-06 09:51:53 +08:00
#!/usr/bin/python3
from datetime import datetime
# print (str(datetime.now().year) + "-" + str(datetime.now().month-1))
print (datetime.now().replace(month=datetime.now().month-1).strftime('%Y-%m'))