python time module | python datetime tutorials | Introduction Part

Namaste Friends,




                             Friends, 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 Site


Q 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.

DirectivesMeaningExample
%aWeekday as locale’s abbreviated name.Mon
%AWeekday as locale’s full name.Monday
%wWeekday as a decimal number, where 0 is Sunday and 6 is Saturday.1
%dDay of the month as a zero-padded decimal number.30
%-dDay of the month as a decimal number. (Platform specific)30
%bMonth as locale’s abbreviated name.Sep
%BMonth as locale’s full name.September
%mMonth as a zero-padded decimal number.09
%-mMonth as a decimal number. (Platform specific)9
%yYear without century as a zero-padded decimal number.13
%YYear with century as a decimal number.2013
%HHour (24-hour clock) as a zero-padded decimal number.07
%-HHour (24-hour clock) as a decimal number. (Platform specific)7
%IHour (12-hour clock) as a zero-padded decimal number.07
%-IHour (12-hour clock) as a decimal number. (Platform specific)7
%pLocale’s equivalent of either AM or PM.AM
%MMinute as a zero-padded decimal number.06
%-MMinute as a decimal number. (Platform specific)6
%SSecond as a zero-padded decimal number.05
%-SSecond as a decimal number. (Platform specific)5
%fMicrosecond as a decimal number, zero-padded on the left.000000
%zUTC offset in the form +HHMM or -HHMM (empty string if the the object is naive).
%ZTime zone name (empty string if the object is naive).
%jDay of the year as a zero-padded decimal number.273
%-jDay of the year as a decimal number. (Platform specific)273
%UWeek 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
%WWeek 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
%cLocale’s appropriate date and time representation.Mon Sep 30 07:06:05 2013
%xLocale’s appropriate date representation.09/30/13
%XLocale’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
SSB :)




Share this

Related Posts

Previous
Next Post »