code-dumps/py/dates-test.py

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'))