How to get the current date to display in a tkinter window How to get the current date to display in a tkinter window tkinter tkinter

How to get the current date to display in a tkinter window


the reason its not updating, is that a constant value is passed to the widget w. we need to change this so that at each update the widget needs to update the date by calling the function again and again.

remove this:

date = dt.datetime.now()format_date = f"{date:%a, %b %d %Y}"w = Label(root, text=format_date, fg="white", bg="black", font=("helvetica", 40))

and add this instead:

w = Label(root, text=f"{dt.datetime.now():%a, %b %d %Y}", fg="white", bg="black", font=("helvetica", 40))