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 windowAuthor & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.