时间处理相关

前言

时间处理相关的一些记录

记录

时间格式类型(2021-03-12 03:34:58.744522)

转换时间为unix时间(13位)

shell下的转换

newtime=$[$(date -d "$mytime" +%s%N)/1000000]

python下的转换

import time
mytime="2021-03-12 03:34:58.744522"
ts=time.strptime(mytime,'%Y-%m-%d %H:%M:%S.%f')
print int(round(time.mktime(ts)*1000))
posted @ 2021-03-16 11:40  武汉-磨渣  阅读(45)  评论(0编辑  收藏  举报