# -*- coding: utf-8 -*-
# date=2020/3/27
import time
def getTimestamp_1770():
now_1770 = round(time.time() - 1770) * 1000
return now_1770
def getTimestamp_1700():
now_1700 = round(time.time() - 1700) * 1000
return now_1700
def timeToTimestamp(timeStr):
# 先转换为时间数组
timeArray = time.strptime(timeStr, "%Y-%m-%d %H:%M:%S")
# 转换为时间戳
timeStamp = int(time.mktime(timeArray)) * 1000
# print(timeStamp)
return timeStamp
def timestampToTime(timeStamp):
timeArray = time.localtime(timeStamp/1000)
timeStamp = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
# print(timeStamp)
return timeStamp
# if __name__ == ‘__main__‘:
# a = timeToTimestamp(‘2020-03-27 13:46:20‘)
#
# a = getTimestamp_1700()
# p = timestampToTime(a)
# print(p)
原文:https://www.cnblogs.com/zhangzhaolin/p/12581257.html