Reputation: 449
timedelta.total_seconds() is not supported in python 2.6. The code below works in python 2.7. Would anybody know how to convert to equivalent in 2.6?
Thanks
import datetime
timestamp = 1414270449
timestamp = int((datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S') - datetime.datetime(1970,1,1)).total_seconds())
Sorry,
I have the same code below. How do I implement total_seconds() in python 2.6 using
(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6`
import datetime
timestamp = '2014-10-24 00:00:00'
timestamp = int((datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S') - datetime.datetime(1970,1,1)).total_seconds())
print timestamp
timestamp = '2014-10-24 00:00:00'
timestamp = datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S') - datetime.datetime(1970,1,1)
print timestamp
Thanks
Upvotes: 1
Views: 5822
Reputation: 336158
It's all in the docs:
Equivalent to
(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
computed with true division enabled.
Upvotes: 8