I have a datetime type and I want to convert it into int but precision in milliseconds. For example I have datetime in UTC 2018-11-19 02:19:53.497 and I want it convert to 1542593993497
Currently the function I wrote is following:
def convert(inputDatetime):
return int((inputDatetime - datetime.datetime(1970,1,1)).total_seconds())
Here the datetime is precision in millionseconds for example, datetime.datetime(2009, 3, 20, 13, 55, 18, 993000)
The function for now can only convert the datetime to int precision in seconds. How should I make the precision to be in millionseconds?
The Python version I am currently use is 2.7