Skip to content

Instantly share code, notes, and snippets.

@bmcculley
Created September 3, 2014 05:26
Show Gist options
  • Save bmcculley/d30f38b9e379d948b20c to your computer and use it in GitHub Desktop.
Save bmcculley/d30f38b9e379d948b20c to your computer and use it in GitHub Desktop.
Get the time in n hours from current time
#!/usr/bin/python
from datetime import datetime, timedelta
def timeFormatted(hoursNum):
ftime = datetime.now() + timedelta(hours=hoursNum)
return '{:%H:%M:%S}'.format(ftime)
# print the time eight hours from now
print timeFormatted(8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment