The following article introduces the Pyhon DateTime module in the actual application process. The classes and methods related to Pyhon DateTime involved in this article, as well as the corresponding code details, I hope you will gain some benefits after reading our article.
The associated modules include time and calendar. The time has been sorted out above. It is easier to calculate the calendar than the time module. Now let's sort out the content above the help document.
Constructor:
- datetime(year,month,day,[hour[,minute[,
second[,microsecond[,tzinfo]]]]])
Parameter description:
- <!--[if !supportLists]-->· <!--[endif]-->MINYEAR
<= year <= MAXYEAR
- <!--[if !supportLists]-->· <!--[endif]-->1 <= month
<= 12
- <!--[if !supportLists]-->· <!--[endif]-->1 <= day
<= number of days in the given month and year
- <!--[if !supportLists]-->· <!--[endif]-->0
<= hour < 24
- <!--[if !supportLists]-->· <!--[endif]-->0
<= minute < 60
- <!--[if !supportLists]-->· <!--[endif]-->0
<= second < 60
- <!--[if !supportLists]-->· <!--[endif]-->0
<= microsecond < 1000000
Sort Pyhon DateTime-related classes and Methods
1. today () returns the current local time value
- if __name__ == '__main__':
- datetimedatetimes = datetime.datetime(2001,12,2)
-
Specify the correct constructor parameters.
- print datetimes.today()
Return Value:
- 2010-03-04 14:40:51.783000
That is, the current time value.
2,
- now([tz])
Example:
- if __name__ == '__main__':
- datetimedatetimes = datetime.datetime(2001,12,2)
- print datetimes.now()
Output:
- 2010-03-04 14:43:09.127000
If no parameter is specified, it indicates the current time value! The above article introduces the actual application solution of Pyhon DateTime.