Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python count down to event (in days and hours)

Please can someone advise on this, I've tried various methods but don't seem to be able to get it to work.

I just need a countdown from

datetime.now()

to

datetime(2011,05,05)

in days hours

like image 976
kieran Avatar asked Dec 21 '22 20:12

kieran


1 Answers

You can use

delta = datetime.datetime(2011, 5, 5) - datetime.datetime.now()

to get a datetime.timedelta object describing the remaining time. The number of remaining days is delta.days, the remaining hours delta.seconds/3600. or delta.seconds//3600.

like image 188
Sven Marnach Avatar answered Dec 24 '22 09:12

Sven Marnach