from common.db.db import dbOP import datetime from datetime import timedelta, date # 数据读入和写入文件 class timeUtils(object): def get_time_hms(self, type=1): '''2023-05-06 09:39:30''' import time if type == 1: t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) return t elif type == 2: t = time.strftime("%Y-%m-%d 00:00:00", time.localtime()) return t elif type == 3: t = time.strftime("%Y-%m-%dT00:00:00.906Z", time.localtime()) return t elif type == 4: one_day_in_seconds = 60 * 60 * 24 tomorrow = time.localtime(time.time() + one_day_in_seconds) t = time.strftime("%Y-%m-%dT00:00:00.906Z", tomorrow) return t elif type == 5: t = time.strftime("%Y-%m-%d", time.localtime()) return t def get_time_add(self, days_aa,type=1): import time if type==1: # t = time.strftime("%Y-%m-%d", datetime.datetime.now()) t = (date.today() + timedelta(days=days_aa)).strftime("%Y-%m-%d %H:%M:%S") return t elif type==2: t = (date.today() + timedelta(days=days_aa)).strftime("%Y-%m-%d") return t