Time Left for New Year

All Sample Codes
We have to run this script to get the time left for new year. To display a countdown timer showing Hours Minutes and seconds left can be shown by using Tkitner.

After the time, on the new year, we can also show the Happy New Year message.
from dateutil.relativedelta import relativedelta
from datetime import datetime
dt=datetime.today()
print("Today:",dt) # current date and time 
print(" No of days left for New year")
dt2=datetime(dt.year+1,1,1,0,0,0) # Date and time for new year
dt3=relativedelta(dt2,dt) # time left for new year 
print("Years:", dt3.years, ", Months:",dt3.months, "Dayes:",dt3.days,
    ",Hours :",dt3.hours,", Minutes :",dt3.minutes, ", Seconds :",dt3.seconds)
Output
Today: 2021-12-27 17:04:00.848590
 No of days left for New year
Years: 0 , Months: 0 Dayes: 4 ,Hours : 6 , Minutes : 55 , Seconds : 59
Displaying Countdown time for new year using Tkinter window

Tkinter window showing countdown in Hour Minute and second left for new year with New year message


All Date Objects Date & Time Exercises
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer