Last active
August 29, 2015 14:04
-
-
Save ip2k/7f02ebe3e537776026aa to your computer and use it in GitHub Desktop.
#pythonTime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time, datetime | |
length=5 # 5 minutes from now | |
start_time = datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%d %H:%M:%S") | |
stop_time = datetime.datetime.strftime(datetime.datetime.now() + datetime.timedelta(minutes=int(length)), "%Y-%m-%d %H:%M:%S") | |
epoch_start_local = int(time.mktime(datetime.datetime.now().timetuple())) | |
epoch_start_utc = int(time.mktime(datetime.datetime.utcnow().timetuple())) | |
epoch_stop_local = int(time.mktime(datetime.datetime.timetuple(datetime.datetime.now() + datetime.timedelta(minutes=length)))) | |
epoch_stop_utc = int(time.mktime(datetime.datetime.timetuple(datetime.datetime.utcnow() + datetime.timedelta(minutes=5)))) | |
# you can clean this up if you only import 'datetime' and 'timedelta' from datetime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment