获取时间

def get_time(self):
        year = datetime.date.today().year
        month = datetime.date.today().month
        firstDayWeekDay, monthRange = calendar.monthrange(year, month)
        start = str(datetime.date(year= year, month= month, day=1))
        end = str(datetime.date(year=year, month=month, day=monthRange))
        return (time.mktime(time.strptime(str(start),'%Y-%m-%d')), 
                time.mktime(time.strptime(str(end),'%Y-%m-%d')))

获取当月第一天和最后一天的datetime格式以及时间戳格式,参考

你可能感兴趣的:(获取时间)