Skip to content

Instantly share code, notes, and snippets.

@itkr
Created March 29, 2016 03:34
Show Gist options
  • Save itkr/593e34ef4d5b4c60b8c6 to your computer and use it in GitHub Desktop.
Save itkr/593e34ef4d5b4c60b8c6 to your computer and use it in GitHub Desktop.
class TransformTools(object):
@staticmethod
def str_to_time(log_date_str):
DATETIME_FORMAT = '%Y/%m/%d %H:%M:%S'
return datetime.strptime(log_date_str, DATETIME_FORMAT)
@staticmethod
def datetime2epoch(target_datetime):
return int(time.mktime(target_datetime.timetuple()))
@staticmethod
def epoch2datetime(epoch):
return datetime.fromtimestamp(int(epoch))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment