Skip to content

Instantly share code, notes, and snippets.

@cansadadeserfeliz
Last active August 29, 2015 13:57
Show Gist options
  • Save cansadadeserfeliz/9811875 to your computer and use it in GitHub Desktop.
Save cansadadeserfeliz/9811875 to your computer and use it in GitHub Desktop.
Python: get days, hours, minutes and seconds form timestamp
import datetime
duration = datetime.timedelta(seconds=1823723) # 21 days, 2:35:23
days, seconds = duration.days, duration.seconds # (21, 9323)
hours = seconds // 3600 # 2
minutes = (seconds % 3600) // 60 # 35
seconds = (seconds % 60) # 23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment