hii readers,
readers, Today, In This Tutorial Series, We Will Learn About How To Use python time module?, how to use python DateTime module?, and how to use python calender modules?. etc.. etc... in brief description and with practical examples.
So, let's start with some basic information.
Q 1. What Python Module Provides?
Ans. Python Time Module Provides Many Time-Related Function Like Getting Current Time, Calculating Time, Comparing Time, and Many More Useful Functions. This Module Come With Python, Pre-Installed. So, You Don't Need To Install This Module Separately.
Read More >>> Python Official SiteQ 2. What Python DateTime Module Provides?
Ans. Python DateTime Module Provides Different Classes For Manipulating Dates And Times In Both Simple And Complex Way. With This Module, We Can Do Really Many Types of Amazing Calculation Related To Dates And Times. And This Modules Is Also Come With Python, Pre-Installed.
Read More >>> Python Official Site Some Important Explanations
Epoch:
In a computing context, the epoch is the point from where computer's clock and timestamp values are determined. like 1st January of that year, at 0 Hour, 0 Minutes, 0 Seconds.
Most Version of Unix, use 1970 as the epoch date; Mac systems use January 1, 1904; windows uses January 1, 1601. Etc.
For Finding You System Epoch time,
Type In Terminal:
# Import Time Module
import time
# Print epoch time
print time.gmtime(0)
Python's strftime Directives:
Directives are very useful because with these directives we can arrange date and time in any specified string format as we want. we only need to pass these directives in function arguments.
hmm, Not Getting, don't worry. I will show you practical usages of these directives in this series.
here, this is list of python strftime directives.
Directives | Meaning | Example |
---|
%a | Weekday as locale’s abbreviated name. | Mon |
%A | Weekday as locale’s full name. | Monday |
%w | Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. | 1 |
%d | Day of the month as a zero-padded decimal number. | 30 |
%-d | Day of the month as a decimal number. (Platform specific) | 30 |
%b | Month as locale’s abbreviated name. | Sep |
%B | Month as locale’s full name. | September |
%m | Month as a zero-padded decimal number. | 09 |
%-m | Month as a decimal number. (Platform specific) | 9 |
%y | Year without century as a zero-padded decimal number. | 13 |
%Y | Year with century as a decimal number. | 2013 |
%H | Hour (24-hour clock) as a zero-padded decimal number. | 07 |
%-H | Hour (24-hour clock) as a decimal number. (Platform specific) | 7 |
%I | Hour (12-hour clock) as a zero-padded decimal number. | 07 |
%-I | Hour (12-hour clock) as a decimal number. (Platform specific) | 7 |
%p | Locale’s equivalent of either AM or PM. | AM |
%M | Minute as a zero-padded decimal number. | 06 |
%-M | Minute as a decimal number. (Platform specific) | 6 |
%S | Second as a zero-padded decimal number. | 05 |
%-S | Second as a decimal number. (Platform specific) | 5 |
%f | Microsecond as a decimal number, zero-padded on the left. | 000000 |
%z | UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive). |
|
%Z | Time zone name (empty string if the object is naive). |
|
%j | Day of the year as a zero-padded decimal number. | 273 |
%-j | Day of the year as a decimal number. (Platform specific) | 273 |
%U | Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. | 39 |
%W | Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. | 39 |
%c | Locale’s appropriate date and time representation. | Mon Sep 30 07:06:05 2013 |
%x | Locale’s appropriate date representation. | 09/30/13 |
%X | Locale’s appropriate time representation. | 07:06:05 |
%% | A literal '%' character. | % |
This Introduction Part Ends Here.
Now, Let's Move ahead and
Check some real examples.
For Next Part Of The Tutorial Click Here.Thanks For Reading,
For More Updates And Tutorials,
Subscribe our blog,
like, comment and share.
Have a Wonderful day
:)