code-dumps/py/dates-test.py
2024-03-06 09:51:53 +08:00

6 lines
200 B
Python
Executable File

#!/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'))