

{"id":9672,"date":"2018-03-01T06:55:49","date_gmt":"2018-03-01T01:25:49","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=9672"},"modified":"2026-04-23T15:31:33","modified_gmt":"2026-04-23T10:01:33","slug":"python-datetime-module","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/","title":{"rendered":"Python Datetime Module with Quick Examples"},"content":{"rendered":"<p>With the ever-complex lifestyle we have adopted, date and time are extremely important. It is like we\u2019re all slaves to time.<\/p>\n<p>In this\u00a0Python Datetime Module tutorial, we will see how to work with Python Datetime Module and\u00a0Python date Objects,\u00a0Python time Objects, Python\u00a0datetime Objects, and\u00a0Python\u00a0timedelta Objects.<\/p>\n<p>You should refer to <a href=\"https:\/\/data-flair.training\/blogs\/python-date-and-time\/\">Python Date and Time<\/a>.<\/p>\n<p>So, let&#8217;s start the Datetime Module in Python.<\/p>\n<div id=\"attachment_9674\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-9674\" class=\"wp-image-9674 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.jpg\" alt=\"Python Datetime Module Overview\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-9674\" class=\"wp-caption-text\">Introduction to Python Datetime Module<\/p><\/div>\n<h3>What is the Python Datetime Module?<\/h3>\n<p>The Python datetime module offers functions and classes for working with date and time parsing, formatting, and arithmetic. Let&#8217;s start with Python Date Time with Examples.<\/p>\n<p>Two kinds of date and time objects exist- na\u00efve and aware.<\/p>\n<p>A na\u00efve object is easier to deal with and doesn\u2019t have enough information to unambiguously locate itself relative to other date\/time objects.<\/p>\n<p>An aware object is more realistic, it knows applicable algorithmic and political time adjustments.<\/p>\n<p>To use this module, we must first import it.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import datetime<\/pre>\n<p>It has the following constants:<\/p>\n<h4>1. MAXYEAR<\/h4>\n<p>MAXYEAR tells us the maximum value a year can take, which is 9999.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.MAXYEAR<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">9999<\/div>\n<h4>2. MINYEAR<\/h4>\n<p>The minimum value of year is 1. This is what MINYEAR returns.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.MINYEAR<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">1<\/div>\n<p>Both MAXYEAR and MINYEAR are of the type integer.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; type(datetime.MAXYEAR),type(datetime.MINYEAR)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">(&lt;class &#8216;int&#8217;&gt;, &lt;class &#8216;int&#8217;&gt;)<\/div>\n<p>Bonus- type() is of the type type.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; type(type)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&lt;class &#8216;type&#8217;&gt;<\/div>\n<p>Other than these constants, the datetime has these datetime class types:<\/p>\n<p><strong>1. <\/strong><b>class datetime.date<\/b><\/p>\n<p>Python date is an idealized na\u00efve date considering the current Gregorian calendar.<br \/>\nAttributes: year, month, and day.<\/p>\n<p><strong>2.<\/strong> <b>class datetime.time<\/b><\/p>\n<p>Python time is an idealized time, independent of any particular day. Here, we assume that each day is made of exactly 24*60*60 seconds (no leap seconds).<br \/>\nAttributes: hour, minute, second, microsecond, and tzinfo.<\/p>\n<p><strong>3.<\/strong> <b>class datetime.datetime<\/b><\/p>\n<p>When you combine a date and a time, you get a datetime.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; issubclass(datetime.datetime,datetime.date)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; issubclass(datetime.datetime,datetime.time)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">False<\/div>\n<p>Attributes: year, month, day, hour, minute, second, microsecond, and tzinfo.<\/p>\n<p><strong>4. <\/strong><b>class datetime.timedelta<\/b><\/p>\n<p>A timedelta is a duration expressing the difference between two date, time, or datetime instances to microsecond resolution.<\/p>\n<p><strong>5.<\/strong> <b>class datetime.tzinfo<\/b><\/p>\n<p>tzinfo is an abstract base class we use for time zone information objects. The date and time classes use it to provide a customizable notion of time adjustment (for example, to account for time zone and\/or DST(daylight saving time)).<\/p>\n<p><strong>6.<\/strong> <b>class datetime.timezone<\/b><\/p>\n<p>timezone implements the tzinfo abstract base class as a fixed offset from UTC.<\/p>\n<p>Such objects are immutable. Also, objects of the type \u2018date\u2019 are na\u00efve, but those of the types \u2018time\u2019 or \u2018datetime\u2019 may be aware or na\u00efve.<\/p>\n<p>The next in the Python Datetime Module Tutorial is Date Objects<\/p>\n<h3>Python Date Objects<\/h3>\n<p>A date object in Python represents a date with year, month, and day, according to the ideal Gregorian calendar.<br \/>\nWith a date object, we have the following methods:<\/p>\n<h4>1. date(year, month, day) method in python<\/h4>\n<p>This method will create an object of type \u2018date\u2019.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d=datetime.date(2018,2,28)<\/pre>\n<p>Here, year can be from MAXYEAR to MINYEAR, and the month can be from 1 to 12. The day can be from 1 to the number of days in the given month for the given year.<\/p>\n<h4>2. today() method in python<\/h4>\n<p>today() will return the current local date.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.date.today()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.date(2018, 2, 28)<\/div>\n<h4>3. fromtimestamp(timestamp) method in python<\/h4>\n<p>fromtimestamp will return the date for the Python timestamp provided.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import time\r\n&gt;&gt;&gt; time.time()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">1519818814.358453<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.date.fromtimestamp(time.time())<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.date(2018, 2, 28)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.date.fromtimestamp(time.time()+999999)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.date(2018, 3, 12)<\/div>\n<p>The date class also has these attributes:<\/p>\n<h4>1. date.min in Python<\/h4>\n<p>It returns the earliest representable date.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.date.min<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.date(1, 1, 1)<\/div>\n<h4>2. date.max in Python<\/h4>\n<p>Like min, max returns the latest representable date.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.date.max<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.date(9999, 12, 31)<\/div>\n<h4>3. date.resolution in Python<\/h4>\n<p>resolution returns the smallest possible difference between non-equal date objects.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.date.resolution<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.timedelta(1)<\/div>\n<p>We also have the following instance attributes:<\/p>\n<h4>1. year attribute in Python<\/h4>\n<p>This returns the year from a date object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d=datetime.date(2018,2,28)\r\n&gt;&gt;&gt; d.year<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">2018<\/div>\n<h4>2. month attribute in Python<\/h4>\n<p>month returns the month from a date object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.month<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">2<\/div>\n<h4>3. day attribute in Python<\/h4>\n<p>This returns the day from a date object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.day<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">28<\/div>\n<p>And then, we have the following instance methods:<\/p>\n<h4>1. replace(year, month, day) method in python<\/h4>\n<p>This will let us update any or all of these three values.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d=d.replace(month=3,day=1)\r\n&gt;&gt;&gt; d<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.date(2018, 3, 1)<\/div>\n<h4>2. timetuple() method in python<\/h4>\n<p>timetuple() returns a tuple of attributes for the current local time.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.timetuple()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">time.struct_time(tm_year=2018, tm_mon=2, tm_mday=28, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=59, tm_isdst=-1)<\/div>\n<h4>3. weekday() method in python<\/h4>\n<p>weekday() will return the day of the week, where 0 denotes Monday.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.weekday()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">2<\/div>\n<h4>4. isoweekday() method in python<\/h4>\n<p>Here, Monday is 1.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.isoweekday()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">3<\/div>\n<h4>5. isocalendar() method in python<\/h4>\n<p>This method returns a tuple of three things- ISO year, ISO week number, and ISO weekday.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.isocalendar()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">(2018, 9, 3)<\/div>\n<h4>6. isoformat() method in python<\/h4>\n<p>This returns the date in the ISO format.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.isoformat()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;2018-02-28&#8217;<\/div>\n<h4>7. __str__() method in python<\/h4>\n<p>This will return the current local date as a string.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.__str__()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;2018-02-28&#8217;<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; str(d)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;2018-02-28&#8217;<\/div>\n<h4>8. ctime() method in python<\/h4>\n<p>ctime returns the current local date in a string format.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.ctime()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;Wed Feb 28 00:00:00 2018&#8217;<\/div>\n<p>We can also perform some operations on a date object:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d=datetime.date(2018,12,30)\r\n&gt;&gt;&gt; td=datetime.timedelta(0,99999)\r\n&gt;&gt;&gt; d1=d+td\r\n&gt;&gt;&gt; d1<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.date(2018, 12, 31)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d1&lt;d<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">False<\/div>\n<p>The Next in Python Datetime Module Tutorial is Time Objects<\/p>\n<h3>Python Time Objects<\/h3>\n<p>A time object represents a local time of day. Its arguments are- hour, minute, second, microsecond, and tzinfo.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t=datetime.time(11,59,59,99999)<\/pre>\n<p>The class time has the following attributes:<\/p>\n<h4>1. min attribute in Python time<\/h4>\n<p>This returns the earliest representable time.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.min<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.time(0, 0)<\/div>\n<h4>2. max attribute in Python time<\/h4>\n<p>This returns the latest representable time.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.max<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.time(23, 59, 59, 999999)<\/div>\n<h4>3. resolution attribute in Python time<\/h4>\n<p>resolution returns the smallest possible difference between non-equal time objects.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.resolution<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.timedelta(0, 0, 1)<\/div>\n<p>Now, let\u2019s look at some non-readable instance attributes:<\/p>\n<h4>1. hour attribute in Python time<\/h4>\n<p>This tells us the hour from the object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.hour<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">11<\/div>\n<h4>2. minute attribute in Python time<\/h4>\n<p>This returns the minute.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.minute<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">59<\/div>\n<h4>3. second attribute in Python time<\/h4>\n<p>This returns the second.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.second<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">59<\/div>\n<h4>4. microsecond attribute in Python time<\/h4>\n<p>This returns the microsecond.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.microsecond<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">99999<\/div>\n<h4>5. tzinfo attribute in Python time<\/h4>\n<p>This returns whatever we pass as tzinfo to the object while creating it. If we didn\u2019t, it returns None.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(t.tzinfo)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">None<\/div>\n<h4>6. fold attribute in Python time<\/h4>\n<p>This disambiguates wall times during a repeated interval.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.fold<\/pre>\n<p>We have the following instance methods:<\/p>\n<h4>1. replace() method in python<\/h4>\n<p>This does the same as for \u2018date\u2019 objects.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t=t.replace(hour=22,second=7)<\/pre>\n<h4>2. isoformat() method in python<\/h4>\n<p>This method returns the time in the object in the ISO format.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.isoformat()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8217;22:59:07.099999&#8242;<\/div>\n<h4>3. __str__() method in python<\/h4>\n<p>This does the same as it does for \u2018date\u2019 objects.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; t.__str__()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8217;22:59:07.099999&#8242;<\/div>\n<p>Now in the Python Datetime Module Tutorial Lets move ahead with datetime Objects<\/p>\n<h3>Python datetime Objects<\/h3>\n<p>A datetime object knows about the date and the time. Arguments include year, month, day, hour, minute, second, microsecond, and tzinfo.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d=datetime.datetime(1995,12,31,10,0)<\/pre>\n<p>We have the following methods:<\/p>\n<h4>1. today() method in python datetime<\/h4>\n<p>This method returns the current local datetime.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.datetime.today()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(2018, 2, 28, 19, 9, 40, 751445)<\/div>\n<h4>2. now() method in python datetime<\/h4>\n<p>now() returns the current local date and time, but is more precise than today().<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.datetime.now()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(2018, 2, 28, 19, 12, 45, 710542)<\/div>\n<h4>3. utcnow() method in python datetime<\/h4>\n<p>utcnow() returns the current UTC time.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.datetime.utcnow()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(2018, 2, 28, 13, 49, 14, 486367)<\/div>\n<h4>4. fromtimestamp() method in python datetime<\/h4>\n<p>This returns the date and time for the provided timestamp.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.datetime.fromtimestamp(time.time())<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(2018, 2, 28, 19, 20, 24, 55451)<\/div>\n<h4>5. utctimestamp() method in python datetime<\/h4>\n<p>This is like the previous one, but it returns the UTC time.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.datetime.utcfromtimestamp(time.time())<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(2018, 2, 28, 13, 51, 56, 615793)<\/div>\n<p>Now, let\u2019s look at the class attributes:<\/p>\n<h4>1. min attribute in Python datetime<\/h4>\n<p>Like for everything else, this returns the earliest representable datetime.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.datetime.min<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(1, 1, 1, 0, 0)<\/div>\n<h4>2. max attribute in Python datetime<\/h4>\n<p>max returns the latest representable datetime.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.datetime.max<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)<\/div>\n<h4>3. resolution attribute in Python datetime<\/h4>\n<p>Resolution is about the smallest possible difference between non-equal datetime objects.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.datetime.resolution<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.timedelta(0, 0, 1)<\/div>\n<p>Now, let\u2019s see some read-only instance attributes:<\/p>\n<h4>1. year attribute in Python datetime<\/h4>\n<p>This returns the year.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.year<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">1995<\/div>\n<h4>2. month attribute in Python datetime<\/h4>\n<p>This returns the month.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.month<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">12<\/div>\n<h4>3. day attribute in Python datetime<\/h4>\n<p>This returns the day.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.day<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">31<\/div>\n<h4>4. hour attribute in Python datetime<\/h4>\n<p>This returns the hour.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.hour<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">10<\/div>\n<h4>5. minute attribute in Python datetime<\/h4>\n<p>This returns the minute.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.minute<\/pre>\n<h4>6. second attribute in Python datetime<\/h4>\n<p>This returns the second.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.second<\/pre>\n<h4>7. microsecond attribute in Python datetime<\/h4>\n<p>This returns the microsecond.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.microsecond<\/pre>\n<h4>8. tzinfo attribute in Python datetime<\/h4>\n<p>This returns the tzinfo; None, if we passed none while creating the object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(d.tzinfo)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">None<\/div>\n<h4>9. fold attribute in Python datetime<\/h4>\n<p>This is the same as we discussed before.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.fold<\/pre>\n<p>Finally, let\u2019s try some instance methods.<\/p>\n<h4>1. replace() method in python datetime<\/h4>\n<p>Again, this is like we have been doing so far.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.replace(microsecond=7)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(1995, 12, 31, 10, 0, 0, 7)<\/div>\n<h4>2. date() method in python datetime<\/h4>\n<p>date() returns a date object from the datetime object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.date()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.date(1995, 12, 31)<\/div>\n<h4>3. time() method in python datetime<\/h4>\n<p>time() returns a time object from the datetime object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.time()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.time(10, 0)<\/div>\n<h4>4. timetz() method in python datetime<\/h4>\n<p>Other than what time() does, timetz() also returns the tzinfo value.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.timetz()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.time(10, 0)<\/div>\n<h4>5. astimezone() method in python datetime<\/h4>\n<p>This returns a datetime object with new tzinfo attribute tz, adjusting the date and time data so the result is the same UTC time as self, but in tz\u2019s local time.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.astimezone()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(1995, 12, 31, 10, 0, tzinfo=datetime.timezone(datetime.timedelta(0, 19800), &#8216;India Standard Time&#8217;))<\/div>\n<h4>6. utcoffset() method in python datetime<\/h4>\n<p>If there is a UTC offset, it returns that, else, None.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(d.utcoffset())<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">None<\/div>\n<h4>7. dst() method in python datetime<\/h4>\n<p>If Daylight Savings Time applies, it returns its magnitude.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(d.dst())<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">None<\/div>\n<h4>8. tzname() method in python datetime<\/h4>\n<p>If you had set tzinfo, this would return its name.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(d.tzname())<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">None<\/div>\n<h4>9. timetuple() method in python datetime<\/h4>\n<p>Like we saw earlier, this returns a time tuple of the object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.timetuple()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">time.struct_time(tm_year=1995, tm_mon=12, tm_mday=31, tm_hour=10, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=365, tm_isdst=-1)<\/div>\n<h4>10. utctimetuple() method in python datetime<\/h4>\n<p>This returns a time tuple of the UTC time.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.utctimetuple()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">time.struct_time(tm_year=1995, tm_mon=12, tm_mday=31, tm_hour=10, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=365, tm_isdst=0)<\/div>\n<h4>11. timestamp() method in python datetime<\/h4>\n<p>This returns the timestamp of the object (in seconds).<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.timestamp()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">820384200.0<\/div>\n<h4>12. weekday() method in python datetime<\/h4>\n<p>This returns the number of weekdays for the object, where 0 is for Monday.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.weekday()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">6<\/div>\n<p>#A Sunday<\/p>\n<h4>13. isoweekday() method in python datetime<\/h4>\n<p>This returns the day of the week, but with Monday as 1.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.isoweekday()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">7<\/div>\n<h4>14. isocalendar() method in Python datetime<\/h4>\n<p>This returns a tuple of the following: ISO year, ISO week number, ISO weekday.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.isocalendar()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">(1995, 52, 7)<\/div>\n<h4>15. isoformat() method in Python datetime<\/h4>\n<p>This returns the date and time in the ISO format.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.isoformat()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;1995-12-31T10:00:00&#8217;<\/div>\n<h4>16. __str__() method in python datetime<\/h4>\n<p>This returns the date and time in a string representation.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.__str__()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;1995-12-31 10:00:00&#8217;<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; str(d)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;1995-12-31 10:00:00&#8217;<\/div>\n<h4>17. ctime() method in Python datetime<\/h4>\n<p>This, like str, returns the datetime as a string.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d.ctime()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;Sun Dec 31 10:00:00 1995&#8217;<\/div>\n<p>Some operations that we can perform on a datetime object are:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d=datetime.datetime(2018,12,30)\r\n&gt;&gt;&gt; td=datetime.timedelta(0,99999)\r\n&gt;&gt;&gt; d1=d+td\r\n&gt;&gt;&gt; d1<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.datetime(2018, 12, 31, 3, 46, 39)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; d&lt;d1<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<h3>Python timedelta Objects<\/h3>\n<p>A timedelta object represents the duration between two dates or times.<\/p>\n<p>Attributes: days, seconds, microseconds, milliseconds, minutes, hours, weeks<\/p>\n<p>Here, seconds can be from 0 to 86399.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; td=datetime.timedelta(9,3,9999,999,58,22,3)<\/pre>\n<p>These attributes belong to the timedelta class:<\/p>\n<h4>1. min attribute in timedelta<\/h4>\n<p>This returns the most negative timedelta object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.timedelta.min<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.timedelta(-999999999)<\/div>\n<h4>2. max attribute in timedelta<\/h4>\n<p>This one returns the most positive timedelta object.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.timedelta.max<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.timedelta(999999999, 86399, 999999)<\/div>\n<h4>3. resolution attribute in timedelta<\/h4>\n<p>resolution returns the smallest possible difference between non-equal timedelta objects.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; datetime.timedelta.resolution<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.timedelta(0, 0, 1)<\/div>\n<p>timedelta also supports one instance method:<\/p>\n<h4>1. total_seconds() method in python timedelta<\/h4>\n<p>This returns the total number of seconds in the duration.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; td.total_seconds()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">2674684.008999<\/div>\n<p>You can perform arithmetic operations on timedelta objects.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; td=datetime.timedelta(0,333)\r\n&gt;&gt;&gt; td1=td*2\r\n&gt;&gt;&gt; td1<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">datetime.timedelta(0, 666)<\/div>\n<p>So, this was all about the Python Datetime Module Tutorial. Hope you like our explanation.<\/p>\n<h3>Python Interview Questions on the Datetime Module<\/h3>\n<ol>\n<li>What is the datetime module in Python?<\/li>\n<li>What is datetime datetime now() in Python?<\/li>\n<li>How to print the date and time in Python?<\/li>\n<li>How do you compare two times in Python?<\/li>\n<li>How does Python calculate a datetime difference?<\/li>\n<\/ol>\n<h3>Conclusion<\/h3>\n<p>We hope that after this article on Python datetime Module Tutorial, and after Date and Time, you will be able to handle all dates and times easily.<\/p>\n<p>Everyone has to start as a beginner, and it\u2019s perfectly okay if you are verifying the syntax very frequently. The more you use these tools in your own projects, the more natural they will feel.<\/p>\n<p>Work on it twice or thrice. Practice will do it for you. And comment if you need any help with Python Datetime examples.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the ever-complex lifestyle we have adopted, date and time are extremely important. It is like we\u2019re all slaves to time. In this\u00a0Python Datetime Module tutorial, we will see how to work with Python&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":9674,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[3560,3567,10468,10469,14681,14726,14734],"class_list":["post-9672","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-date-objects","tag-datetime-objects","tag-python-datetime-example","tag-python-datetime-module","tag-the-python-datetime","tag-time-objects","tag-timedelta-objects"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Datetime Module with Quick Examples - DataFlair<\/title>\n<meta name=\"description\" content=\"Get Python Datetime Module with Quick Python Datetime Examples and Explanations. Learn Date objects, Time Objects, Datetime Objects, timedelta objects.\" \/>\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-datetime-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Datetime Module with Quick Examples - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Get Python Datetime Module with Quick Python Datetime Examples and Explanations. Learn Date objects, Time Objects, Datetime Objects, timedelta objects.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-datetime-module\/\" \/>\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=\"2018-03-01T01:25:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-23T10:01:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.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=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Datetime Module with Quick Examples - DataFlair","description":"Get Python Datetime Module with Quick Python Datetime Examples and Explanations. Learn Date objects, Time Objects, Datetime Objects, timedelta objects.","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-datetime-module\/","og_locale":"en_US","og_type":"article","og_title":"Python Datetime Module with Quick Examples - DataFlair","og_description":"Get Python Datetime Module with Quick Python Datetime Examples and Explanations. Learn Date objects, Time Objects, Datetime Objects, timedelta objects.","og_url":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-03-01T01:25:49+00:00","article_modified_time":"2026-04-23T10:01:33+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.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":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Datetime Module with Quick Examples","datePublished":"2018-03-01T01:25:49+00:00","dateModified":"2026-04-23T10:01:33+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/"},"wordCount":2038,"commentCount":2,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.jpg","keywords":["date objects","datetime objects","python datetime example","Python Datetime Module","The Python Datetime","time objects","timedelta objects"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-datetime-module\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/","url":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/","name":"Python Datetime Module with Quick Examples - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.jpg","datePublished":"2018-03-01T01:25:49+00:00","dateModified":"2026-04-23T10:01:33+00:00","description":"Get Python Datetime Module with Quick Python Datetime Examples and Explanations. Learn Date objects, Time Objects, Datetime Objects, timedelta objects.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-datetime-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-datetime-Module-01.jpg","width":1200,"height":628,"caption":"Introduction to Python Datetime Module"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-datetime-module\/#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 Datetime Module with Quick 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\/9672","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=9672"}],"version-history":[{"count":22,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/9672\/revisions"}],"predecessor-version":[{"id":147811,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/9672\/revisions\/147811"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/9674"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=9672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=9672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=9672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}