Python's time module provides a rich range of how-to-work methods that can be used to accomplish this requirement.
Time.time (): Gets the current timestamp
Time.ctime (): String form of the current time
Time.localtime (): The Struct_time form of the current time.
Time.strftime (): Used to get the current time, you can format the time.
Note: Python formats symbols in time date (case sensitive), as shown in table 8.1.
| Instructions |
Meaning |
| %a |
Abbreviation of the day of the week |
| %A |
Full name of the day of the week |
| %w |
Decimal indicates day of the week (value from 0-6, Sunday is 0) |
| %d |
The day ordinal of a month represented in decimal |
| %b |
Shorthand for the month |
| %B |
Full name of the month |
| %m |
The Month in decimal notation |
| %y |
Decimal year without century (values from 0 to 99) |
| %Y |
Decimal year with part of century |
| %H |
24 Hours of production |
| %I |
12-Hour Hour |
| %p |
Equivalent display of the local AM or PM |
| %M |
The number of minutes represented in decimal |
| %s |
Number of seconds in decimal |
| %f |
Decimal subtle, 0 padding to the left |
| %Z |
The name of the current time zone |
| %j |
The first day of the year in decimal notation |
| %u |
Number of weeks in the year (00-53), Sunday for the beginning of the week |
| %W |
Number of weeks in the year (00-53), Monday for the beginning of the week |
| %x |
Local corresponding date representation |
| %x |
Local corresponding time representation |
| %% |
% number itself |
|
|
Python's Time representation