# ! /Usr/bin/Python
# Coding = UTF-8
Import Time
From Datetime Import Datetime
"""
Class that represents the time used in daily use. It is an embedded class implemented in C.
Features are simple but efficient. The time range is limited from January 1, January 1-20, 1970 to January 1, January 19.
"""
"""
Current Time
Returns a float type with a fixed time epoch (the number of seconds elapsed since, January 1, January 1, 1970)
Because time is represented by float, the problem of timespan is basically a numerical problem.
"""
Now = Time. Time ()
"""
Return a time structure using localtime,
These include the tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst = 0 summer time mark.
Tm_wday indicates the week, 0 indicates Monday, and 6 indicates Sunday.
"""
Now = time. localtime (now)
# If the current time is returned, you can simply write it
Time. localtime ()
# The UTC time is returned.
Time. gmtime ()
"""
Convert to string
% Y two-digit year (00-99)
% Y indicates the four-digit year (000-9999)
% M month (01-12)
One day in % d month (0-31)
% H hour in 24-hour format (0-23)
% I 12-hour (01-12)
% M minutes (00 = 59)
% S seconds (00-59)
% A local simplified week name
% A local full week name
% B local simplified month name
% B local full month name
% C local Date and Time
% J one day in the year (001-366)
% P local equivalent of a. m. or P. M.
% U number of weeks in a year (00-53) Sunday is the start of the week
% W Week (0-6), Sunday is the beginning of the week
% W number of weeks in a year (00-53) Monday is the start of the week
% X local date Representation
% X Local Time Representation
% Z Current Time Zone name
% Itself
"""
Time. strftime ( " % Y-% m-% d % H: % m: % s " , Now)
# If you print the current time, you can also simply write it
Strtime = time. strftime ( " % Y-% m-% d % H: % m: % s " )
"""
String to Time Structure
"""
Time. strptime (strtime, " % Y-% m-% d % H: % m: % s " )
"""
Use tuple to construct a Time Structure
The values are year, month, day, hour, minute, and second, and the latter two values are both 0, which is automatically calculated. The last one is written as 0.
"""
Past = (2010, 11, 12, 13, 14, 15, 0, 0)
Time. localtime (time. mktime (past ))
"""
Convert to datetime type
Http://www.cnblogs.com/goodspeed/archive/2011/11/06/python_datetime.html
"""
Print Datetime. fromtimestamp (Time. Time ())