# coding:utf-8
import datetime,time
class GetTime(object):
#获取格式化时间
def getTime(self):
now = datetime.datetime.now()
otherStyleTime = now.strftime("%Y-%m-%d %H:%M:%S")
return otherStyleTime
#日期转字符串%Y-%m-%d %H:%M:%S
def getTimeToString(self,str):
otherStyleTime = str.strftime("%Y-%m-%d %H:%M:%S")
return otherStyleTime
#日期转字符串%Y%m%d%H%M%S
def getTimeToString2(self, str):
otherStyleTime = str.strftime("%Y-%m-%d %H:%M:%S")
return otherStyleTime
# 字符串%Y%m%d%H%M%S 转%Y-%m-%d %H:%M:%S
def getTimeString2(self, str):
otherStyleTime = datetime.datetime.strptime(str, "%Y%m%d%H%M%S")
otherStyleTime = otherStyleTime.strftime("%Y-%m-%d %H:%M:%S")
return otherStyleTime
#字符串%Y-%m-%d %H:%M:%S转%Y%m%d%H%M%S
def getTimeString(self,str):
otherStyleTime = datetime.datetime.strptime(str, "%Y-%m-%d %H:%M:%S")
otherStyleTime = otherStyleTime.strftime("%Y%m%d%H%M%S")
return otherStyleTime
def getTimeStrings(self,str):
otherStyleTime = datetime.datetime.strptime(str, "%Y%m%d%H%M%S")
return otherStyleTime
#获取系统时间的毫秒级时间戳
def getIntTime(self):
return int(round(time.time()*1000))