Hi ,
Thank you all, despite all trying to help, but i couldn't understand.
I have managed to solve it myself. Hence, i will just share with whoever looking for solutions too.
Then split the timestamp and add to its own array with datetime format.
Perform the time difference calculation.
And finally print the output. // change the printing output if you need it differently.
Thank you all, despite all trying to help, but i couldn't understand.
I have managed to solve it myself. Hence, i will just share with whoever looking for solutions too.
from datetime import datetime, timedelta # epoch timestamp in microseconds arr = [ '1519649295496484 -> 1519649327106949', '1519649400617116 -> 1519649400728112', '1519649441795007 -> 1519649442855342', '1519649654498861 -> 1519649655227328' ] epoch = datetime(1970, 1, 1) if len(arr): for line in arr: tmp = [] dateTimes = line.split('->') for epochTime in dateTimes: cookie_microseconds_since_epoch = int(epochTime) cookie_datetime = epoch + timedelta(microseconds=cookie_microseconds_since_epoch) tmp.append(cookie_datetime) for index, item in enumerate(tmp): if len(tmp) == index + 1: break elapsedTime = tmp[index + 1] - item print str(item) + ' -> ' + str(tmp[index + 1]) + ' : ' + str(elapsedTime)
Output:2018-02-26 12:48:15.496484 -> 2018-02-26 12:48:47.106949 : 0:00:31.610465
2018-02-26 12:50:00.617116 -> 2018-02-26 12:50:00.728112 : 0:00:00.110996
2018-02-26 12:50:41.795007 -> 2018-02-26 12:50:42.855342 : 0:00:01.060335
2018-02-26 12:54:14.498861 -> 2018-02-26 12:54:15.227328 : 0:00:00.728467
This solution will get a list of timestamp with native epoch timestamp.Then split the timestamp and add to its own array with datetime format.
Perform the time difference calculation.
And finally print the output. // change the printing output if you need it differently.