1 #Encoding=utf-82 Import Time3 4 #return Timestamp5 Printtime.time ()6 7 #The delayed operating unit is S, with the following delay of 3s8Time.sleep (3)9 Ten #convert timestamp to time tuple (time object), from 1970+second, whose second is seconds One PrintTime.gmtime (4) A - #convert timestamp to local object - Printtime.localtime () the - #converting a timestamp to a string - PrintTime.asctime (Time.localtime ()) - + #converting a timestamp to a string - PrintTime.ctime (5) + A #convert local time to timestamp att = (2009, 2, 17, 17, 3, 38, 1, 48, 0) - Printtime.mktime (t) - - #converts a time object to a canonical string (commonly used) in the following format - " " - %Y year with century as a decimal number. in %m Month as a decimal number [01,12]. - %d day of the month as a decimal number [01,31]. to %H Hour (24-hour clock) as a decimal number [00,23]. + %M Minute as a decimal number [00,59]. - %s Second as a decimal number [00,61]. the %z time zone offset from UTC. * %a Locale ' s abbreviated weekday name. $ %A Locale ' s full weekday name.Panax Notoginseng %b Locale ' s abbreviated month name. - %B Locale ' s full month name. the %c Locale ' s appropriate date and time representation. + %I Hour (12-hour clock) as a decimal number [01,12]. A %p Locale ' s equivalent of either AM or PM. the " " + PrintTime.strftime ('%y-%m-%d%h-%m-%s', T) - $ #converts a time string to an array of time based on a specified format character $Struct_time = Time.strptime ("From the Nov","%d%b%y") - PrintStruct_time
The time module for Python