어제

from datetime import datetime, date, timedelta

yesterday = date.today() - timedelta(1)
yesterday_text = yesterday.strftime('%Y-%m-%d 00:00:00')

달의 첫번째 일

from datetime import datetime, date, timedelta
import calendar


now_date = datetime.datetime.now()
month_frist_text = now_date.replace(day = 1).strftime("%Y-%m-%d 00:00:00")

달의 마지막 일

from datetime import datetime, date, timedelta
import calendar

now_date = datetime.datetime.now()
month_last_text = now_date.replace(day = calendar.monthrange(now_date.year, now_date.month)[1]).strftime("%Y-%m-%d 23:59:59")

 


to Top