#!/usr/bin/python3 # Time stamp import time print (" The current timestamp is :", time.time()) # Interval between function executions import time def calculateTime(): item = 1 for i in range(1,100000): item = item + i return item startTime = time.time() result = calculateTime() endTime = time.time() print(' The result of the calculation is :'+ str(result)) print(' execution time :'+ str(endTime - startTime)) # Pause time import time for i in range(2): print('one') print(time.time()) time.sleep(1) print('two') print(time.time()) time.sleep(1) print(' Run complete ') # Current date and time import datetime print(datetime.datetime.now()) # Get the specified time datetest = datetime.datetime(2019,9,30,22,22,0) print(datetest) print(str(datetest.year)+"-"+str(datetest.month)+"-"+str(datetest.day)+" "+str(datetest.hour)+":"+str(datetest.minute)+":"+str(datetest.second)) # Convert timestamps to datetime object dt1 = datetime.datetime.fromtimestamp(10000) dt2 = datetime.datetime.fromtimestamp(time.time()) print(dt1) print(dt2) # Date conversion datestr = datetime.datetime.strptime('2019-9-30 22:10:00', '%Y-%m-%d %H:%M:%S') print(datestr) now = datetime.datetime.now() print(now.strftime('%a, %b %d %H:%M')) # Date increase and decrease now = datetime.datetime.now() print(now) newdate = now + datetime.timedelta(hours=10) print(newdate) newdate = now - datetime.timedelta(days=1) print(newdate)