python - How to get the value from a timedelta? -


when sqlalchemy returns:

{u'age': datetime.timedelta(12045),} 

how 12045? i've tried str(), strftime(), , bunch of others, nothing works.

from docs, use .total_seconds() length of timedelta. note timedelta you've provided showing days value, timedelta includes seconds , microseconds well. if want days, use .days.

age = datetime.timedelta(12045) print(age.total_seconds())  # 1040688000.0 print(age.days)  # 12045, not full value represented delta 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -