How do you update variable in Class each time?

Solution 1:

This is not a good case for a class definition. A simple function will work:

def time_now():
     return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

print(time_now())

Solution 2:

This method should work for what you want, but requires making an instance of TimeNow

import datetime

command = ""

class TimeNow:
    @property
    def time_now(self): 
        return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

instance = TimeNow()
    
while command != "quit":
    command = input("-> ").lower()
    if command == "1":
    
         print(instance.time_now)