0

Can somebody explain the Datetime module a little bit better?

Just need help learning how to tell distance between two dates, how to tell certain things, like only the time, or only the date.

5th Aug 2019, 2:26 AM
Akul Khanna
3 Answers
+ 3
#you can play around with this from datetime import * a = datetime(2018, 8, 5) #chosen year,month,day (today of last year) b = datetime.today() #todays date daysBetween = int(list(str(b-a).split())[0]) #this will give days between last year(specified date a) to today (b) daysTimeBetween = b-a #this will give days/time between last year (a) and today (b) print(daysTimeBetween) print(daysBetween) d = list(str(date.today()).split("-")) #store each element of todays date day = int(d[2]) month = int(d[1]) year = int(d[0]) print(datetime.today()) #todays date and time print(day, month, year) https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_datetime.asp
5th Aug 2019, 2:59 AM
Jake
Jake - avatar