Timedalte is an object in DateTime that represents the difference constructor for two times: Datetime.timedelta (days=0, seconds=0, microseconds=0, Milliseconds=0, Minutes=0, Hours=0, weeks=0)
Where the arguments are optional, the default value is 0
The following should be common sense, and almost everyone knows:
1 millisecond = 1000 microseconds
1 minute = seconds
1 hour = 3600 seconds
1 week = 7 days
In constructors, the range of parameter values is as follows:
0 <= microseconds < 1000000
0 <= seconds < 3600*24 (the number of seconds in one day)
-999999999 <= days <= 999999999
Timedalte has three read-only properties:
Timedelta.min: Negative number of the maximum time difference, equivalent to Timedelta (-999999999).
Timedelta.max: The maximum time difference of a positive number, equivalent to Timedelta (days=999999999, hours=23, minutes=59, seconds=59, microseconds=999999).
Timedelta.resolution: The minimum difference of two time is equivalent to Timedelta (Microseconds=1).
Three read-only property instances:
From datetime import Date,timedelta
print (Timedelta.max); #999999999 days, 23:59:59.999999
print ( days=999999999, hours=23, minutes=59, seconds=59, microseconds=999999); #999999999 days, 23:59:59.999999
print ( timedelta.min); #-999999999 days, 0:00:00
print (Timedelta ( -999999999)); #-999999999 days, 0:00:00
print ( timedelta.resolution); #0:00:00.000001
print (Timedelta (Microseconds=1)); #0:00:00.000001
Timedelta.total_seconds () Method: Returns the value of the time difference in seconds
Examples of the above:
From datetime import Datetime,date,timedelta now
= DateTime.Now ();
NextDay = Now + timedelta (days = 1), #增加一天后的时间
Nextsecond = Now + timedelta (seconds = 1), #增加一秒后的时间
span = Now -NextDay #获取时间差对象
print (now);
Print (nextday);
Print (nextsecond);
Print (Span.total_seconds ()); #获取时间差 in seconds
The above to learn to tidy up a bit, if there is a mistake, please correct me. Thank you