千家信息网

unix时间戳转换成正常YYYY-MM-DD HH-MM-S

发表于:2025-01-22 作者:千家信息网编辑
千家信息网最后更新 2025年01月22日,def stringToUnix(string):unixTime = time.mktime(time.strptime(string,"%Y-%m-%d %H:%M:%S"))return str
千家信息网最后更新 2025年01月22日unix时间戳转换成正常YYYY-MM-DD HH-MM-S

def stringToUnix(string):

unixTime = time.mktime(time.strptime(string,"%Y-%m-%d %H:%M:%S"))

return str(unixTime)


def newUnixTime(time_input, oldtimeList):

newUnixTimeList = []

for oldtime in oldtimeList:

olddatetime = datetime.fromtimestamp(int(oldtime))

dayAndhms = str(olddatetime).split(" ")

newtime = time_input + ' ' + dayAndhms[1]

new_Time = stringToUnix(newtime)

newUnixTimeList.append(new_Time)

return newUnixTimeList


0