

{"id":5585,"date":"2017-12-31T09:39:38","date_gmt":"2017-12-31T04:09:38","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=5585"},"modified":"2026-04-22T17:15:18","modified_gmt":"2026-04-22T11:45:18","slug":"python-date-and-time","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/","title":{"rendered":"Python Date and Time &#8211; Syntax and examples"},"content":{"rendered":"<h3>1. Python Date and Python Time<\/h3>\n<p>Our last session was on\u00a0<a href=\"https:\/\/data-flair.training\/blogs\/python-variables-and-data-types\/\">data types and constructs of Python<\/a>. Here, we will talk about the Python date and time module. Moreover, we will discuss Python Time and Python Date. Along with this, we will learn about Python time tuple and Python time module.<\/p>\n<p>A computer often has to perform the task of converting between different date and time formats. For this, Python provides the time and calendar modules.<\/p>\n<p><strong>Use of date and time in Python:<\/strong><\/p>\n<ul>\n<li>It helps in scheduling calendars and tracks the upcoming events.<\/li>\n<li>It makes it easier to find out the difference between the two dates or times.<\/li>\n<li>It supports the formatting of dates and times to get user-friendly results.<\/li>\n<li>While entering data, an event or a file, the date and time are added to make searches easier.<\/li>\n<\/ul>\n<p>So, let&#8217;s start Python Date and Time.<\/p>\n<div id=\"attachment_42808\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-42808\" class=\"size-full wp-image-42808\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg\" alt=\"Python Date and Time - Syntax and examples\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-42808\" class=\"wp-caption-text\">Python Date and Time &#8211; Syntax and examples<\/p><\/div>\n<h3>2. Introduction to Python\u00a0Date and Time<\/h3>\n<p>To see how Python handles date and time, let\u2019s first look at some important concepts of Python time. You can refer to our article on<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-datetime-module\/\"> Python Datetime Module with Quick Examples<\/a><\/strong><\/p>\n<h4>a. Epoch<\/h4>\n<p>The Epoch is the point in<em> time in Python<\/em> from which time is measured. It is labelled 12:00 AM, Jan 1, 1970. It is the beginning of an era.<\/p>\n<h4>b. Ticks<\/h4>\n<p>In Python, a tick is a floating-point number in seconds, and it denotes a time <em>interval in Python.<\/em> Ticks are calculated from the epoch.<\/p>\n<h4>c. Daylight Savings Time(DST)<\/h4>\n<p>In an agrarian culture, they set the clocks to be one hour faster. This way, they get up an hour before the actual sunrise and get an hour extra after work. In northern and southern regions, days are considerably longer in the summer. However, in areas around the equator, the difference isn\u2019t that much for DST to be efficient. Hence, not every country implements it. Before proceeding with Python time tuple, you may also want to read our article on <strong><a href=\"https:\/\/data-flair.training\/blogs\/python-tuples-syntax-examples\/\">python tuples.<\/a><\/strong><\/p>\n<h3>3. Python Time Tuple<\/h3>\n<p>We represent Python time in a way that\u2019s easy for us to understand. However, Python stores it in tuples. These Python tuples are made of nine numbers.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"208\"><strong>Index<\/strong><\/td>\n<td width=\"208\"><strong>Field<\/strong><\/td>\n<td width=\"208\"><strong>Domain of Values<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"208\">0<\/td>\n<td width=\"208\">Year (4 digits)<\/td>\n<td width=\"208\">Ex.- 1995<\/td>\n<\/tr>\n<tr>\n<td width=\"208\">1<\/td>\n<td width=\"208\">Month<\/td>\n<td width=\"208\">1 to 12<\/td>\n<\/tr>\n<tr>\n<td width=\"208\">2<\/td>\n<td width=\"208\">Day<\/td>\n<td width=\"208\">1 to 31<\/td>\n<\/tr>\n<tr>\n<td width=\"208\">3<\/td>\n<td width=\"208\">Hour<\/td>\n<td width=\"208\">0 to 23<\/td>\n<\/tr>\n<tr>\n<td width=\"208\">4<\/td>\n<td width=\"208\">Minute<\/td>\n<td width=\"208\">0 to 59<\/td>\n<\/tr>\n<tr>\n<td width=\"208\">5<\/td>\n<td width=\"208\">Second<\/td>\n<td width=\"208\">0 to 61 (60\/61 are leap seconds)<\/td>\n<\/tr>\n<tr>\n<td width=\"208\">6<\/td>\n<td width=\"208\">Day of Week<\/td>\n<td width=\"208\">0 to 6 (Monday to Sunday)<\/td>\n<\/tr>\n<tr>\n<td width=\"208\">7<\/td>\n<td width=\"208\">Day of Year<\/td>\n<td width=\"208\">1 to 366 (Julian day)<\/td>\n<\/tr>\n<tr>\n<td width=\"208\">8<\/td>\n<td width=\"208\">DST<\/td>\n<td width=\"208\">-1,0,1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Leap seconds are added to make up for Earth\u2019s slowing rotation. When DST is 0, it isn\u2019t applied. When it\u2019s 1, it is applied. However, when it is -1, it is up to the library to determine that.<\/p>\n<p>This tuple has an equivalent struct_time structure.<\/p>\n<h3>4. Getting the Number of Ticks<\/h3>\n<p>First, we\u2019ll look at the Python \u2018time\u2019 module. To use<strong> <a href=\"https:\/\/data-flair.training\/blogs\/python-functions\/\">functions <\/a><\/strong>from it,\u00a0 you must import it in your program. See h<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; import time<\/pre>\n<p>If you wanted to import a single method from \u2018time\u2019, you would do it this way.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; from time import time\r\n&gt;&gt;&gt; time()<\/pre>\n<p>1514472272.5830126<\/p>\n<p>To get how many ticks have passed since the epoch, we call the Python time() method.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; import time\r\n&gt;&gt;&gt; time.time()<\/pre>\n<p>1514472318.761928<\/p>\n<p>This is the number of ticks that have yet passed from the epoch. Clearly, this isn\u2019t very human-readable. We can read it, but with only this information, we can\u2019t instantly perceive how much time has passed. Read our article on <strong><a href=\"https:\/\/data-flair.training\/blogs\/python-functions\/\">Python Functions with Syntax and Examples<\/a><\/strong><\/p>\n<h3>5. Getting the Local Time<\/h3>\n<p>To get the current time in Python in a more perceivable Python Date Time format, we use the localtime() method instead. It returns the Python time according to the area you\u2019re in.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.localtime()<\/pre>\n<p>time.struct_time(tm_year=2017, tm_mon=12, tm_mday=28, tm_hour=20, tm_min=17, tm_sec=48, tm_wday=3, tm_yday=362, tm_isdst=0)<\/p>\n<p>This still isn\u2019t completely instantly perceivable. Let\u2019s try something else yet.<\/p>\n<h3>6. Getting the Formatted Time<\/h3>\n<p>When we use the asctime() method, we get something much more readable.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.asctime()<\/pre>\n<p>&#8216;Thu Dec 28 20:22:55 2017&#8217;<\/p>\n<p>It only takes us about a second to read this and understand.<\/p>\n<p>You can also provide a tuple or a struct_time structure as an argument.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.asctime(time.localtime())<\/pre>\n<p>&#8216;Thu Dec 28 20:24:52 2017&#8217;<\/p>\n<p>But the plain time() method doesn\u2019t work with it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.asctime(time.time())<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#31&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>time.asctime(time.time())<\/p>\n<p>TypeError: Tuple or struct_time argument required<\/p>\n<p><strong>Read:<\/strong> <strong><a href=\"https:\/\/data-flair.training\/blogs\/python-packages\/\">Python Packages Comprehensive Guide<\/a><\/strong><\/p>\n<h3>7. Python Calendar<\/h3>\n<p>\u2018calendar\u2019 is yet another module available in Python. It lets you play with monthly and yearly calendars using a variety of functions.<br \/>\nTo get the calendar for Dec 2017, we use the month() method.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.month(2017,12)<\/pre>\n<p>&#8216;\u00a0\u00a0 December 2017\\nMo Tu We Th Fr Sa Su\\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1\u00a0 2\u00a0 3\\n 4\u00a0 5\u00a0 6\u00a0 7\u00a0 8\u00a0 9 10\\n11 12 13 14 15 16 17\\n18 19 20 21 22 23 24\\n25 26 27 28 29 30 31\\n&#8217;<\/p>\n<p>I\u2019m guessing we should use the print function here to make this readable.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; print(calendar.month(2017,12))<\/pre>\n<p>December 2017<\/p>\n<p>Mo Tu We Th Fr Sa Su<\/p>\n<p>1\u00a0 2\u00a0 3<\/p>\n<p>4 \u00a0\u00a05 \u00a0\u00a06\u00a0 \u00a07 \u00a0\u00a08\u00a0 \u00a09 \u00a010<\/p>\n<p>11 12 13 14 15 16 17<\/p>\n<p>18 19 20 21 22 23 24<\/p>\n<p>25 26 27 28 29 30 31<\/p>\n<h3>8. Methods in the Python Time Module<\/h3>\n<p>Do refer<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-method\/\"> Python Method \u2013 Classes, Objects and Functions in Python <\/a><\/strong>before proceeding.<\/p>\n<p>The three methods we discussed aren\u2019t the only ones applicable on the Python time module. One by one, we\u2019ll see them all.<\/p>\n<h4>a. time() method in Python<\/h4>\n<p>We already saw this in section 4. Let\u2019s get the number of ticks once again.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.time()<\/pre>\n<p>1514474057.2921965<\/p>\n<p>This method does not take any parameters. And if you set the clock back before making another call to this method, it may return a lower value.<\/p>\n<h4>b. localtime() method in Python<\/h4>\n<p>This is the second method we discussed in the text. It returns the current time according to your geographical location, in a more readable format.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.localtime()<\/pre>\n<p>time.struct_time(tm_year=2017, tm_mon=12, tm_mday=28, tm_hour=21, tm_min=2, tm_sec=13, tm_wday=3, tm_yday=362, tm_isdst=0)<\/p>\n<p>This returns a time tuple.<\/p>\n<p>However, localtime() may take an argument in seconds. Then, it returns a time tuple for that number of seconds from the epoch. First, let\u2019s try providing 0 seconds as an argument.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.localtime(0)<\/pre>\n<p>time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=5, tm_min=30, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)<\/p>\n<p>We just discussed that the epoch is 12:00, Jan 1, 1970. Why then did it return 5:30? Well, that\u2019s because we\u2019re here in India. Our time zone is UTC+05:30 (UTC stands for Coordinated Universal Time).<\/p>\n<p>Now, let\u2019s try it for 777 seconds.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.localtime(777)<\/pre>\n<p>time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=5, tm_min=42, tm_sec=57, tm_wday=3, tm_yday=1, tm_isdst=0)<\/p>\n<h4>c. asctime() method in Python<\/h4>\n<p>This method gives us the current time in a very readable format. It returns a string of 24 characters.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.asctime()<\/pre>\n<p>&#8216;Thu Dec 28 21:17:39 2017&#8217;<\/p>\n<p>It may also take a Python time tuple as an argument. Since the localtime() method returns a time tuple, let\u2019s use it as the argument.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.asctime(time.localtime())<\/pre>\n<p>&#8216;Thu Dec 28 21:21:36 2017&#8217;<\/p>\n<h4>d. clock() method in Python<\/h4>\n<p>The clock method does not take any arguments. On Windows, it returns the number of seconds elapsed since the first call made to it. It returns the value as a floating number. Let\u2019s try it a few times.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.clock()<\/pre>\n<p>0.0<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.clock()<\/pre>\n<p>5.456429169367129<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.clock()<\/pre>\n<p>9.670899252239298<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.clock()<\/pre>\n<p>16.96956734536135<\/p>\n<p>However, it does not return 0.0 on the first call.<\/p>\n<p>Now, if you restart the shell, the next time you call it, it will assume it to be the first call.<\/p>\n<h4>e. gmtime() method in Python<\/h4>\n<p>Remember the problem we faced in localtime(0), about UTC? Well, gmtime() converts the current time into UTC before returning it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.gmtime()<\/pre>\n<p>time.struct_time(tm_year=2017, tm_mon=12, tm_mday=28, tm_hour=16, tm_min=11, tm_sec=3, tm_wday=3, tm_yday=362, tm_isdst=0)<\/p>\n<p>It may also take seconds as an argument. Let\u2019s try gmtime(0).<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.gmtime(0)<\/pre>\n<p>time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)<\/p>\n<p>Like localtime(), it returns a time tuple.<\/p>\n<h4>f. ctime() method in Python<\/h4>\n<p>This method is equivalent to asctime().<\/p>\n<h4>g. mktime() method in Python<\/h4>\n<p>The mktime() method takes a time tuple as an argument, and returns the equivalent amount of ticks\/seconds. It returns in floating point.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.mktime(time.localtime())\r\n<\/pre>\n<p>1514478943.0<\/p>\n<p>You can\u2019t however, call it without an argument.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.mktime()<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#72&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>time.mktime()<\/p>\n<p>TypeError: mktime() takes exactly one argument (0 given)<\/p>\n<p><strong>Read:<a href=\"https:\/\/data-flair.training\/blogs\/python-collections-module\/\"> Python Collections Module \u2013 Python Counter, DefaultDict, OrderedDict, NamedTuple<\/a><\/strong><\/p>\n<h4>h. sleep() method in Python<\/h4>\n<p>When called, sleep() holds the execution for a given number of seconds. This number is passed to it as an argument.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.asctime(); time.sleep(2); time.asctime()<\/pre>\n<p>&#8216;Thu Dec 28 22:11:55 2017&#8217;<\/p>\n<p>&#8216;Thu Dec 28 22:11:57 2017&#8217;<\/p>\n<h4>i. strftime() method in Python<\/h4>\n<p>Now, what if you wanted to display the Python date and time in the format you wish to? The strftime() method takes a format and optionally, a Python time tuple, and returns the date in the format you specify. The syntax is as follows.<br \/>\nTime.strftime(format[, t])<br \/>\nYou can apply the following directives in the format, as per your needs.<\/p>\n<ul>\n<li>%a &#8211; abbreviated day of week<\/li>\n<li>%A &#8211; full day of the week<\/li>\n<li>%b &#8211; abbreviated name of month<\/li>\n<li>%B &#8211; full name of month<\/li>\n<li>%c &#8211; preferred date and time representation<\/li>\n<li>%C &#8211; century number (the year divided by 100; range 00 to 99)<\/li>\n<li>%d &#8211; day of month (1 to 31)<\/li>\n<li>%D &#8211; the same as %m\/%d\/%y<\/li>\n<li>%e &#8211; day of month (1 to 31)<\/li>\n<li>%g &#8211; like %G, but without the century<\/li>\n<li>%G &#8211; 4-digit year corresponding to the ISO week number (ref. %V).<\/li>\n<li>%h &#8211; same as %b<\/li>\n<li>%H \u2013 hour; using a 24-hr clock (0 to 23)<\/li>\n<li>%I \u2013 hour; using a 12-hr clock (1 to 12)<\/li>\n<li>%j &#8211; day of year (1 to 366)<\/li>\n<li>%m &#8211; month (1 to 12)<\/li>\n<li>%M &#8211; minute<\/li>\n<li>%n &#8211; newline character<\/li>\n<li>%p \u2013 AM\/PM according to given time value<\/li>\n<li>%r &#8211; time in AM\/PM representation<\/li>\n<li>%R &#8211; time in 24-hr representation<\/li>\n<li>%S &#8211; second<\/li>\n<li>%t &#8211; tab<\/li>\n<li>%T &#8211; current time; equal to %H:%M:%S<\/li>\n<li>%u \u2013 day of week as a number (1 to 7); Monday=1<\/li>\n<li>%U &#8211; week of year, beginning with the first Sunday as the first day of the first week<\/li>\n<li>%V &#8211; The ISO 8601 week of year (1 to 53); week 1 is the first with at least 4 days in the current year, and with Monday as the first day of the week<\/li>\n<li>%W &#8211; week of year; beginning with the first Monday as the first day of the first week<\/li>\n<li>%w &#8211; day of week as a decimal; Sunday=0<\/li>\n<li>%x &#8211; the preferred date representation without the time<\/li>\n<li>%X &#8211; the preferred time representation without the date<\/li>\n<li>%y &#8211; year without century (00 to 99)<\/li>\n<li>%Y &#8211; year including century<\/li>\n<li>%Z or %z &#8211; time zone\/name\/abbreviation<\/li>\n<li>%% &#8211; a % character<\/li>\n<\/ul>\n<p>Let\u2019s try printing the shortened name of the month in the local time in Python.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.strftime(\"%b\",time.localtime())<\/pre>\n<p>&#8216;Dec&#8217;<\/p>\n<p>Let\u2019s try another one.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.strftime(\"%B %uth, '%y\",time.localtime())<\/pre>\n<p>&#8220;December 4th, &#8217;17&#8221;<\/p>\n<p>As you can see, it is possible to add letters in this <a href=\"https:\/\/data-flair.training\/blogs\/python-strings\/\"><strong>python string<\/strong> <\/a>normally.<\/p>\n<h4>j. Python strptime() method in Python<\/h4>\n<p>We just saw that the strftime() method returns a string from a format (and optionally, a tuple). The strptime() takes such a string and parses it. Finally, it returns a time tuple. It takes two arguments; the following is the syntax.<\/p>\n<p>Time.strptime(string[,format])<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.strptime(\"31 Dec 1995\",\"%d %b %Y\")<\/pre>\n<p>time.struct_time(tm_year=1995, tm_mon=12, tm_mday=31, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=365, tm_isdst=-1)<\/p>\n<h3>9. Attributes of the time Module<\/h3>\n<h4>a. altzone<\/h4>\n<p>This returns the local DST timezone\u2019s offset. While it returns a positive value for locations west of UTC, it returns a negative value for those east of UTC.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.altzone<\/pre>\n<p>-23400<\/p>\n<p>From where we write this article, we can tell that we live east of UTC. Note that this attribute\u2019s value does not change for a location.<\/p>\n<h4>b. timezone<\/h4>\n<p>The timezone attribute is the same as altzone, but it does not consider DST.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.timezone<\/pre>\n<p>-19800<\/p>\n<h4>c. tzname<\/h4>\n<p>Finally, you can use this attribute to print the name of the local time zone with and without DST.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; time.tzname<\/pre>\n<p>(&#8216;India Standard Time&#8217;, &#8216;India Daylight Time&#8217;)<\/p>\n<h3>10. Methods in the Calendar Module<\/h3>\n<p>Like the time module, the calendar provides us with some methods too. Let\u2019s see what we can do with it.<\/p>\n<h4>a. isleap() method in Python<\/h4>\n<p>isleap() takes a 4-digit year as an argument, and returns True if it is a leap year. Otherwise, it returns False.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.isleap(2019)<\/pre>\n<p>False<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.isleap(2020)<\/pre>\n<p>True<\/p>\n<h4>b. leapdays(y1,y2) method in Python<\/h4>\n<p>Talking of leap years, this one returns the total number of leap days from year y1 to year y2.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.leapdays(1990,2020)<\/pre>\n<p>7<\/p>\n<h4>c. firstweekday() method in Python<\/h4>\n<p>This one returns which day is currently set as the first day of the week. By default, this is 0.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.firstweekday()<\/pre>\n<h4>d. setfirstweekday() method in Python<\/h4>\n<p>Complementary to what we learnt in the above point, setfirstweekday() allows us to set the first day of the week to what we want. 0 is for Monday, 6 is for Sunday.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.setfirstweekday(4)\r\n&gt;&gt;&gt; calendar.firstweekday()<\/pre>\n<p>4<\/p>\n<p>Now, let\u2019s print the calendar for this January.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; print(calendar.month(2018,1))<\/pre>\n<p>January 2018<\/p>\n<p>Fr Sa Su Mo Tu We Th<\/p>\n<p>1 \u00a0\u00a0\u00a02 \u00a0\u00a0\u00a03 \u00a0\u00a0\u00a04<\/p>\n<p>5\u00a0 \u00a06\u00a0 \u00a07\u00a0 \u00a08\u00a0 \u00a0\u00a09 \u00a0\u00a010 \u00a011<\/p>\n<p>12 13 14 15 16 \u00a017 \u00a018<\/p>\n<p>19 20 21 22 23 \u00a024 \u00a025<\/p>\n<p>26 27 28 29 30 \u00a031<\/p>\n<p>As you can see, the calendar now begins at Friday. However, this change of information is invalidated once the shell is restarted. That is, it changes back to 0.<\/p>\n<h4>e. month() method in Python<\/h4>\n<p>As we have seen so far in this document, month() returns a calendar for a certain month of a certain year. These are two of the arguments. There are two other optional arguments- one for width of characters in name of day, and one for the number of lines for each week.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; print(calendar.month(2017,12,3,2))<\/pre>\n<p>December 2017<\/p>\n<p>Mon Tue Wed Thu Fri Sat Sun<\/p>\n<p>1\u00a0\u00a0 2\u00a0\u00a0 3<\/p>\n<p>4\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a05\u00a0 \u00a0 \u00a06\u00a0 \u00a0 7\u00a0\u00a0 \u00a0\u00a08\u00a0\u00a0 \u00a09\u00a0 \u00a010<\/p>\n<p>11 \u00a0\u00a012 \u00a0\u00a013\u00a0 \u00a014 \u00a0\u00a015 \u00a0\u00a016\u00a0 \u00a0\u00a017<\/p>\n<p>18\u00a0 \u00a019 \u00a0\u00a020 \u00a0\u00a021 \u00a0\u00a022 \u00a0\u00a023\u00a0 \u00a0\u00a024<\/p>\n<p>25\u00a0 \u00a026 \u00a0\u00a027\u00a0 \u00a028\u00a0 \u00a029\u00a0 \u00a030\u00a0 \u00a0\u00a031<\/p>\n<h4>f. calendar() method in Python<\/h4>\n<div id=\"attachment_5587\" style=\"width: 1930px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/calendar.calendar2018.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5587\" class=\"wp-image-5587 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/calendar.calendar2018.png\" alt=\"calendar() in Python \" width=\"1920\" height=\"1080\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/calendar.calendar2018.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/calendar.calendar2018-150x84.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/calendar.calendar2018-300x169.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/calendar.calendar2018-768x432.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/calendar.calendar2018-1024x576.png 1024w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><p id=\"caption-attachment-5587\" class=\"wp-caption-text\">Python Date and Time &#8211; Calendar() in Python<\/p><\/div>\n<p>The calendar() method returns the calendar for an entire year. It may also take three optional parameters. These are- width of characters for day of week, lines for week, spaces between columns.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; print(calendar.calendar(2018))<\/pre>\n<h4>g. monthcalendar() method in Python<\/h4>\n<p>This method returns a list of lists of day numbers as lists. Also, it takes two arguments- year and month.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; print(calendar.monthcalendar(2017,12))<\/pre>\n<p>[[0, 0, 0, 0, 1, 2, 3], [4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31]]<\/p>\n<h4>h. monthrange() method in Python<\/h4>\n<p>Now this method takes two arguments- year and month. Then, it returns the day of the week for the first day of the month, and the number of days in the month.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; print(calendar.monthrange(2017,12))<\/pre>\n<p>(4, 31)<\/p>\n<p>Here, 4 is for Friday.<\/p>\n<h4>i. prcal() method in Python<\/h4>\n<p>If you want to skip the print statement to the calendar method, use prcal() instead. Let\u2019s take the following code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt;calendar.prcal(2018)<\/pre>\n<p>Its output is the same as that of the code in point 6 in this section.<\/p>\n<h4>j. prmonth() method in Python<\/h4>\n<p>It\u2019s the same thing here as well. It prints out the calendar for the specified month.<\/p>\n<h4>k. weekday() method in Python<\/h4>\n<p>This method takes as arguments the year, the month, and the day. Then, it returns which day of the week it is.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.weekday(2018,11,30)<\/pre>\n<p>4<\/p>\n<h4>l. timegm() method in Python<\/h4>\n<p>Finally, this method takes a time tuple and returns the equivalent in ticks since the epoch, in floating point.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.timegm(time.localtime())<\/pre>\n<p>1514504864<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; calendar.timegm(time.localtime())<\/pre>\n<p>1514504872<\/p>\n<p><strong>Read:<a href=\"https:\/\/data-flair.training\/blogs\/python-career-opportunities\/\"> The Tremendous Python Career Opportunities<\/a><\/strong><\/p>\n<p>So, this was all about Python Date and Time. Hope you like our explanation.<\/p>\n<h3>Conclusion<\/h3>\n<p>We learned a lot today, didn\u2019t we? First, we learned about some concepts of Python date and time, like the epoch, ticks, and DST. Then, we used the Python time and calendar modules, and their methods and attributes. Why don\u2019t you try to use this knowledge to create a console-based game?<\/p>\n<p>Still Confuse in Python Date and Time? Share your query\/ feedback with us in the comments section<\/p>\n<p><strong><a href=\"https:\/\/docs.python.org\/2\/library\/datetime.html\">Reference<\/a><\/strong><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:2175,&quot;href&quot;:&quot;https:\\\/\\\/docs.python.org\\\/2\\\/library\\\/datetime.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251009044405\\\/https:\\\/\\\/docs.python.org\\\/2\\\/library\\\/datetime.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-11 01:38:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-31 11:39:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-06 07:14:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-12 13:52:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-21 09:59:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-24 17:15:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-04 22:55:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 22:43:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-13 04:47:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-22 03:39:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-13 22:58:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 17:37:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-22 08:53:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-29 17:40:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-09 23:46:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-20 04:55:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-30 09:10:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-06 03:19:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-12 22:07:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-23 13:45:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-29 12:04:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-08-02 16:42:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-08-09 03:21:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-08-22 08:52:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-08-30 23:38:41&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-08-30 23:38:41&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Python Date and Python Time Our last session was on\u00a0data types and constructs of Python. Here, we will talk about the Python date and time module. Moreover, we will discuss Python Time and&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":42808,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[3555,3559,10467,10890,14722,14724],"class_list":["post-5585","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-date-and-time-in-python","tag-date-in-python","tag-python-date-and-time","tag-python-time-and-date","tag-time-and-date-in-python","tag-time-in-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Date and Time - Syntax and examples - DataFlair<\/title>\n<meta name=\"description\" content=\"Python date and Time- Python date Syntax, Python Time Example, Python Calander example, Python Time Tuple, Python time Module\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-date-and-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Date and Time - Syntax and examples - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Python date and Time- Python date Syntax, Python Time Example, Python Calander example, Python Time Tuple, Python time Module\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-date-and-time\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-31T04:09:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-22T11:45:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Date and Time - Syntax and examples - DataFlair","description":"Python date and Time- Python date Syntax, Python Time Example, Python Calander example, Python Time Tuple, Python time Module","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/","og_locale":"en_US","og_type":"article","og_title":"Python Date and Time - Syntax and examples - DataFlair","og_description":"Python date and Time- Python date Syntax, Python Time Example, Python Calander example, Python Time Tuple, Python time Module","og_url":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2017-12-31T04:09:38+00:00","article_modified_time":"2026-04-22T11:45:18+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Date and Time &#8211; Syntax and examples","datePublished":"2017-12-31T04:09:38+00:00","dateModified":"2026-04-22T11:45:18+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/"},"wordCount":2517,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg","keywords":["date and time in python","date in python","python date and time","python time and date","time and date in python","time in python"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-date-and-time\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/","url":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/","name":"Python Date and Time - Syntax and examples - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg","datePublished":"2017-12-31T04:09:38+00:00","dateModified":"2026-04-22T11:45:18+00:00","description":"Python date and Time- Python date Syntax, Python Time Example, Python Calander example, Python Time Tuple, Python time Module","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-date-and-time\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Python-Date-and-Time-01-768x402-1.jpg","width":1200,"height":628,"caption":"Python Date and Time - Syntax and examples"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-date-and-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Date and Time &#8211; Syntax and examples"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=5585"}],"version-history":[{"count":10,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5585\/revisions"}],"predecessor-version":[{"id":147804,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5585\/revisions\/147804"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/42808"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=5585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=5585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=5585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}