How to organize the Pyhon DateTime module in related class methods

Source: Internet
Author: User

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:

 
 
  1. datetime(year,month,day,[hour[,minute[,
    second[,microsecond[,tzinfo]]]]]) 

Parameter description:

 
 
  1. <!--[if !supportLists]-->· <!--[endif]-->MINYEAR
     <= year <= MAXYEAR   
  2. <!--[if !supportLists]-->· <!--[endif]-->1 <= month
     <= 12   
  3. <!--[if !supportLists]-->· <!--[endif]-->1 <= day
     <= number of days in the given month and year   
  4. <!--[if !supportLists]-->· <!--[endif]-->0 
    <= hour < 24   
  5. <!--[if !supportLists]-->· <!--[endif]-->0
     <= minute < 60   
  6. <!--[if !supportLists]-->· <!--[endif]-->0 
    <= second < 60   
  7. <!--[if !supportLists]-->· <!--[endif]-->0 
    <= microsecond < 1000000   

Sort Pyhon DateTime-related classes and Methods

1. today () returns the current local time value

 
 
  1. if __name__ == '__main__':  
  2. datetimedatetimes = datetime.datetime(2001,12,2)  
  3.  

Specify the correct constructor parameters.

 
 
  1. print datetimes.today() 

Return Value:

 
 
  1. 2010-03-04 14:40:51.783000  

That is, the current time value.

2,

 
 
  1. now([tz]) 

Example:

 
 
  1. if __name__ == '__main__':  
  2. datetimedatetimes = datetime.datetime(2001,12,2)  
  3. print datetimes.now()  

Output:

 
 
  1. 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.