Python Time module Time&datetime

Source: Internet
Author: User

Time Module

Time classification: Timestamp, structured time, format time

time.  Time (): Returns a timestamp  of |1506933253.4386108, the second time since the birth of Unix in 1970 . Asctime ([t]): Convert gmtime () and LocalTime () returns a tuple or Struct_time as a string. | Mon Oct 2 16:32:56time. Clock (): Returns the duration of the program's run at the time of the first call. The time after the second time is returned with the previous interval. That is, when the CPU executes the program | 4.280515904898922e-07

Time . CTime ([secs]): Converts the timestamp to a time string, if not provided, returns the current time string, as with Asctime (LocalTime ()). | Mon Oct 2 16:32:56
  time  .gmtime ([secs]): Converts the timestamp to, UTC Time zone Struct_time. This is the British Standard Time zone, not our time zone |time.struct_time (tm_year=2017, tm_mon=10, tm_mday=2, Tm_hour=8, tm_min=35, tm_sec= Tm_wday=0, tm_yday=275, tm_isdst=0)  time  .localtime ([secs]): Similar to Gmtime () but would convert him to cost time zone. | Time.struct_time (tm_year=2017, tm_mon=10, tm_mday=2, tm_hour=16, tm_min=36, tm_sec=42, tm_wday=0, tm_yday=275, tm_ isdst=0)  time  .mktime (t): Struct_time Convert to timestamp.  time . sleep   (secs): The thread defers the specified time, in seconds. 
time .strftime (Format[,t]): Converts a sturc_time or tuple to a string based on a parameter. |
Print (Time.strftime ( '%y.%m.%d ', Time.localtime () )) |2017.10.02
time. Strptime (string[, format]): In contrast to Strftime, returns a struct_time structured. can only be printed on a yearly or monthly date | Print (Time.strptime (' 2015.04.1 ', '%y.%m.%d '))   |time.struct_time (tm_year=2015, tm_mon=4, Tm_mday=1, TM _hour=0, Tm_min=0, tm_sec=0, tm_wday=2, tm_yday=91, Tm_isdst=-1)

formatting strings commonly used in time modules

1%y Two-digit yearxx~ About.2%Y Four-digit year0000~99993%m Month on~ A.4%d Day on~ to.5When%Hxx~ at.6%I When on~ A.7%M minxx~ -.8%s secondsxx~ A.

DateTime module
print (Datetime.datetime.now ()) -Geneva: £º43.907458 

Python Time module Time&datetime

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.