Feb-06-2021, 11:49 PM
(This post was last modified: Feb-06-2021, 11:49 PM by project_science.)
I solved it, and the time stamps looks approximately difference by 1.01s, which I assume means there's 0.01s need for processing time. I'm assuming there's a better way to do time deltas, but for data logging, I think this would be ok, no?
from datetime import datetime import time print("\n*Timestamps*") def time_stamps(): return datetime.now() # object to class datatime x = time_stamps() time.sleep(1) y = time_stamps() print(x) print(y) # Time Delays #time.sleep(1) # wait 1 second (s) #time.sleep(1/1000) # wait 1 millisecond (ms) #time.sleep(1/1000000) # wait 1 microsecond (us) #time.sleep(1 / 100000000) # wait 1 nanosecond (ns) if x > y: print("\ninstance 1 (x) is greater by: ",abs(x-y), "seconds") else: print("\ninstance 2 (y) is greater by:", abs(x-y), "seconds") print("\n*DATETIME attributes use *") now = datetime.now() # create an object to class datetime print("today = ", now.date()) # returns year-month-day print("month =",now.year) # year print("year =",now.month) # month print("day =", now.day) # day print("hour =", now.hour) # hours print("minute =", now.minute) # minutes print("seconds =", now.second) # seconds print("microseconds =", now.microsecond) # microseconds # print all attributes in class datetime print("\n*DATETIME attributes use *") for x in dir(datetime): print(x)