-1

I want the diff between two timestamps which are available to me as list of strings.

date_list = ['Tue Sep 25 21:12:32 PDT 2018', 'Tue Sep 25 21:15:27 PDT 2018']

How do I get the difference in minutes or in hours ?

I saw some examples, but they are using different format of UNIX timestamp. I can't change the given date format.

1

1 Answer 1

1

I suggest to use dateutil. For instance

from dateutil import parser

d1 = parser.parse(date_list[0])
d2 = parser.parse(date_list[1])

at this point d1 and d2 are standard datetime objects and you can use the standard methods/operators to operate on them

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.