python時間共通クラス
1064 ワード
import time,datetime
class DateUtils(object):
def unix_millisecond(self):
''' ,
'''
return int(time.time() * 1000)
def unix_second(self):
''' , '''
return int(time.time())
def in_hours(self,hour=-1):
'''
,
:param hour:
:return:
'''
return (datetime.datetime.now() + datetime.timedelta(hours=hour)).strftime("%Y-%m-%d %H:%M:%S")
def in_days(self,day=-1):
'''
,
:param day:
:return:
'''
return (datetime.datetime.now() + datetime.timedelta(days=day)).strftime("%Y-%m-%d %H:%M:%S")
def in_minutes(self,minute=-1):
'''
,
:param day:
:return:
'''
return (datetime.datetime.now() + datetime.timedelta(minutes=minute)).strftime("%Y-%m-%d %H:%M:%S")