Reputation: 1133
I have the code snippet as follows:
import time
now = time.time()
evt_time='2022-10-20T04:10:36Z'
diff_time = now - pd.to_datetime(evt_time, unit='s')
This results in an error. Primarily because the now
is in epoch time and the evt_time
needs to be converted.
How do I achieve this conversion? I need the result in epoch time...
Thanks!
Upvotes: 0
Views: 22
Reputation: 260790
You can use Timestamp.timestamp
to convert to epoch:
import time
now = time.time()
evt_time = '2022-10-20T04:10:36Z'
diff_time = now - pd.Timestamp(evt_time).timestamp()
diff_time
example output: 157054.39800930023
Upvotes: 1