@@ -11,6 +11,7 @@ def __init__(self, font=None):
1111 self .set_font (font )
1212 self .add_header ()
1313 self .add_clock ()
14+ self .add_date () # ✅ Added new method to show date
1415 self .update_time_on_clock ()
1516
1617 def create_window (self ):
@@ -39,6 +40,19 @@ def add_clock(self):
3940 'times' , 90 , 'bold' ), bg = 'blue' , fg = 'white' )
4041 self .clock .grid (row = 2 , column = 2 , padx = 620 , pady = 250 )
4142
43+ def add_date (self ):
44+ """Add a date label below the clock."""
45+ self .date_label = Label (self .window , font = ('times' , 40 , 'bold' ), bg = 'black' , fg = 'white' )
46+ self .date_label .grid (row = 3 , column = 2 )
47+ self .update_date_on_clock ()
48+
49+ def update_date_on_clock (self ):
50+ """Update the date displayed below the clock."""
51+ currentDate = time .strftime ("%d-%b-%Y" )
52+ self .date_label .config (text = currentDate )
53+ # Update every midnight (24*60*60*1000 ms)
54+ self .date_label .after (86400000 , self .update_date_on_clock )
55+
4256 def update_time_on_clock (self ):
4357 """Update the time displayed on the clock every second."""
4458 currentTime = time .strftime ("%H:%M:%S" )
@@ -53,4 +67,3 @@ def start(self):
5367if __name__ == "__main__" :
5468 clock = DigitalClock ()
5569 clock .start ()
56-
0 commit comments