Tkinter-How to get the current date to display in a tkinter window?

To display the current date in tkinter window, we will use the datetime library.

date =

Steps −

  • Import the required libraries and create an instance of tkinter frame.

  • Set the size of the frame using geometry method.

  • Call and store the value in a variable "date".

  • Next, create a label to display the date. In the text parameter of the label, pass the date value and format the data as text=f"{date:%A, %B %d, %Y}".

    • %A – Day of the week, full name

    • %B – Full month name

    • %d – Day of the month

    • %Y – Year with century as a decimal number

  • Finally, run the mainloop of the application window.

Example −

# Import the libraries
from tkinter import *
import datetime as dt

# Create an instance of tkinter
win = Tk()
win.title("Display Current Date")

date =
# Create Label to display the Date
label = Label(win, text=f"{date:%A, %B %d, %Y}", font="Calibri, 20")



On execution, it will produce the following output −

Updated on: 26-Oct-2021

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started