def datetime_to_ms(dt):
"""
Convert an unaware datetime object to milliseconds. This will
be a UTC time. The SMC stores all times in UTC and will do the
time conversions based on the local timezone.
Example of converting a datetime to milliseconds::
utc_time = datetime.strptime("2018-06-04T00:00:00", "%Y-%m-%dT%H:%M:%S")
datetime_to_ms(utc_time)
:param dt datetime: pass in python datetime object.
:return: value representing the datetime in milliseconds
:rtype: int
"""
return int(time.mktime(dt.timetuple()) * 1000)
评论列表
文章目录