Python의 시간 함수 | 세트-2(날짜 조작)

시간 함수 중 일부는 다음에서 논의됩니다. 세트 1 Python을 사용하여 'datetime' 모듈과 'date' 클래스를 사용하여 날짜 조작을 수행할 수도 있습니다. 날짜에 대한 작업: 1. 미니이어 :- 다음을 표시합니다. 최소 연도 날짜 클래스를 사용하여 표현할 수 있습니다. 2. 맥년 :- 다음을 표시합니다. 최대 연도 that can be represented using date class. Python
   # Python code to demonstrate the working of   # MINYEAR and MAXYEAR   # importing built in module datetime   import   datetime   from   datetime   import   date   # using MINYEAR to print minimum representable year   print   (  'Minimum representable year is : '    end  =  ''  )   print   (  datetime  .  MINYEAR  )   # using MAXYEAR to print maximum representable year   print   (  'Maximum representable year is : '    end  =  ''  )   print   (  datetime  .  MAXYEAR  )   
Output:
Minimum representable year is : 1 Maximum representable year is : 9999  

3. 날짜(yyyy-mm-dd) :- 이 함수는 전달된 인수를 연도, 월, 날짜 순으로 문자열로 반환합니다. 4. 오늘() :- 반환 현재 날짜 in the format yyyy-mm-dd. Python
   # Python code to demonstrate the working of   # date() and today()   # importing built in module datetime   import   datetime   from   datetime   import   date   # using date() to represent date   print   (  'The represented date is : '    end  =  ''  )   print   (  datetime  .  date  (  1997    4    1  ))   # using today() to print present date   print   (  'Present date is : '    end  =  ''  )   print   (  date  .  today  ())   
Output:
The represented date is : 1997-04-01 Present date is : 2016-08-02  

5. 타임스탬프(초) :- 그것은 다음을 반환합니다 초 단위로 계산된 날짜 인수에 언급된 시대 이후 경과되었습니다. 6. 분() :- 이것은 다음을 반환합니다 최소 날짜 날짜 클래스로 표현할 수 있습니다. 7. 최대() :- 이것은 다음을 반환합니다 최대 날짜 that can be represented by date class. Python
   # Python code to demonstrate the working of   # fromtimestamp() min() and max()   # importing built in module datetime   import   datetime   from   datetime   import   date   # using fromtimestamp() to calculate date   print   (  'The calculated date from seconds is : '    end  =  ''  )   print   (  date  .  fromtimestamp  (  3452435  ))   # using min() to print minimum representable date   print   (  'Minimum representable date is : '    end  =  ''  )   print   (  date  .  min  )   # using max() to print minimum representable date   print   (  'Maximum representable date is : '    end  =  ''  )   print   (  date  .  max  )   
Output:
The calculated date from seconds is : 1970-02-09 Minimum representable date is : 0001-01-01 Maximum representable date is : 9999-12-31