I'm trying to convert a date string into an age.
The string is like: "Mon, 17 Nov 2008 01:45:32 +0200" and I need to work out how many days old it is.
I have sucessfully converted the date using:
>>> time.strptime("Mon, 17 Nov 2008 01:45:32 +0200","%a, %d %b %Y %H:%M:%S +0200")
(2008, 11, 17, 1, 45, 32, 0, 322, -1)
For some reason %z gives me an error for the +0200 but it doesn't matter that much.
I can get the current time using:
>>> time.localtime()
(2009, 2, 3, 19, 55, 32, 1, 34, 0)
but how can I subtract one from the other without going though each item in the list and doing it manually?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…