{"id":184,"date":"2019-02-06T22:17:21","date_gmt":"2019-02-06T22:17:21","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/python\/?p=184"},"modified":"2020-07-26T09:09:42","modified_gmt":"2020-07-26T09:09:42","slug":"13-python-date-and-time","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/","title":{"rendered":"Python &#8211; Date and Time"},"content":{"rendered":"<p>We would cover date and time data type in Python. Then we learn how to convert date and time data.<\/p>\n<p>&nbsp;<\/p>\n<p>We would cover the following<\/p>\n<ol>\n<li><a href=\"#t1\">What is a Tick?<\/a><\/li>\n<li><a href=\"#t2\">Basics of Time Tuple<\/a><\/li>\n<li><a href=\"#t3\">Formatting Time Data<\/a><\/li>\n<li><a href=\"#t4\">Creating a Calendar<\/a><\/li>\n<li><a href=\"#t5\">The time Module<\/a><\/li>\n<li><a href=\"#t6\">The calendar Module<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Let&#8217;s start by explaining the concept of tick<\/p>\n<p><strong id=\"t1\">1. What is a Tick?<\/strong><\/p>\n<p>A tick is an interval of time in Python given in seconds. This is number of seconds from 12:00 a.m, January 1 1970.<\/p>\n<p>Python contains a module called time. This modules provides what you need to work with time in Python. To use it, you need to <strong>add import<\/strong> time statement.<\/p>\n<p>So to get the current time, you use the function time.time(). Let&#8217;s see how it work.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">time<\/span>\r\n\r\ncurrentTime <span style=\"color: #333333;\">=<\/span> time<span style=\"color: #333333;\">.<\/span>time()\r\n<span style=\"color: #007020;\">print<\/span>(currentTime)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The above code would give the output of\u00a01549478219.6221974. This is because it returns time in seconds.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Basics of Time Tuple<\/strong><\/h4>\n<p>You remember a tuple is a collection of items. You can review <a href=\"https:\/\/www.kindsonthegenius.com\/python\/python-tuples\/\">tuples here<\/a>. Now, in Python, time is represented as a tuple of 9 items. These 9 items are explained in the table below<\/p>\n<table class=\"table table-bordered\">\n<tbody>\n<tr>\n<th>Index<\/th>\n<th>Field<\/th>\n<th>Values<\/th>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>4-digit year<\/td>\n<td>2019<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>Month number<\/td>\n<td>1 to 12<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Day of month<\/td>\n<td>1 to 31<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Hour<\/td>\n<td>0 to 23<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>Minute<\/td>\n<td>0 to 59<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>Second<\/td>\n<td>0 to 61 (60 or 61 are leap-seconds)<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>Day of Week number<\/td>\n<td>0 to 6 (0 is Monday, 1 is Tuesday, etc)<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>Day of year<\/td>\n<td>1 to 366 (Julian day)<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">8<\/td>\n<td class=\"ts\">Daylight savings<\/td>\n<td>-1, 0, 1, -1 means library determines DST<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Formatting Time Data<\/strong><\/h4>\n<p>You can get formatted time by using the format by using the asctime() function. This would produce time in a friendly format.<\/p>\n<p>For example<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">time<\/span>\r\n\r\ncurrentTime <span style=\"color: #333333;\">=<\/span> time<span style=\"color: #333333;\">.<\/span>asctime()\r\n<span style=\"color: #007020;\">print<\/span>(currentTime)\r\n<\/pre>\n<p>If you run the code above, then you will have a formatted time as shown below:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">Wed Feb  <span style=\"color: #0000dd; font-weight: bold;\">6<\/span> <span style=\"color: #0000dd; font-weight: bold;\">22<\/span>:<span style=\"color: #0000dd; font-weight: bold;\">27<\/span>:<span style=\"color: #0000dd; font-weight: bold;\">33<\/span> <span style=\"color: #0000dd; font-weight: bold;\">2019<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. Creating a Calendar<\/strong><\/h4>\n<p>You can create and display a calendar in Python. You can do this using functions in the calendar module. Therefore, you need to import the calendar module.<\/p>\n<p>For example, the code below would create a calendar.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">calendar<\/span>\r\n\r\n<span style=\"color: #888888;\"># Calender of February 2019<\/span>\r\nmycalendar <span style=\"color: #333333;\">=<\/span> calendar<span style=\"color: #333333;\">.<\/span>month(<span style=\"color: #0000dd; font-weight: bold;\">2019<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">2<\/span>)\r\n<span style=\"color: #007020;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"Current Calendar\"<\/span>)\r\n<span style=\"color: #007020;\">print<\/span>(mycalendar)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If your run the code below, a calendar would be formatted and displayed as shown in below.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">Current Calendar\r\n   February <span style=\"color: #0000dd; font-weight: bold;\">2019<\/span>\r\nMo Tu We Th Fr Sa Su\r\n             <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>  <span style=\"color: #0000dd; font-weight: bold;\">2<\/span>  <span style=\"color: #0000dd; font-weight: bold;\">3<\/span>\r\n <span style=\"color: #0000dd; font-weight: bold;\">4<\/span>  <span style=\"color: #0000dd; font-weight: bold;\">5<\/span>  <span style=\"color: #0000dd; font-weight: bold;\">6<\/span>  <span style=\"color: #0000dd; font-weight: bold;\">7<\/span>  <span style=\"color: #0000dd; font-weight: bold;\">8<\/span>  <span style=\"color: #0000dd; font-weight: bold;\">9<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>\r\n<span style=\"color: #0000dd; font-weight: bold;\">11<\/span> <span style=\"color: #0000dd; font-weight: bold;\">12<\/span> <span style=\"color: #0000dd; font-weight: bold;\">13<\/span> <span style=\"color: #0000dd; font-weight: bold;\">14<\/span> <span style=\"color: #0000dd; font-weight: bold;\">15<\/span> <span style=\"color: #0000dd; font-weight: bold;\">16<\/span> <span style=\"color: #0000dd; font-weight: bold;\">17<\/span>\r\n<span style=\"color: #0000dd; font-weight: bold;\">18<\/span> <span style=\"color: #0000dd; font-weight: bold;\">19<\/span> <span style=\"color: #0000dd; font-weight: bold;\">20<\/span> <span style=\"color: #0000dd; font-weight: bold;\">21<\/span> <span style=\"color: #0000dd; font-weight: bold;\">22<\/span> <span style=\"color: #0000dd; font-weight: bold;\">23<\/span> <span style=\"color: #0000dd; font-weight: bold;\">24<\/span>\r\n<span style=\"color: #0000dd; font-weight: bold;\">25<\/span> <span style=\"color: #0000dd; font-weight: bold;\">26<\/span> <span style=\"color: #0000dd; font-weight: bold;\">27<\/span> <span style=\"color: #0000dd; font-weight: bold;\">28<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t5\">5. The time Module<\/strong><\/h4>\n<p>The time module in Python provides many methods you can use to manipulate time. Especially for converting times between different formats.<\/p>\n<p>Table below provides a list of methods available in the time module.<\/p>\n<table class=\"table table-bordered\">\n<tbody>\n<tr>\n<th>SN<\/th>\n<th>Function and brief description<\/th>\n<\/tr>\n<tr>\n<td class=\"ts\">1<\/td>\n<td><strong>time.altzone<\/strong>Gives the offset of the local DST timezone, in seconds west of UTC, if defined. It would be negative if the local DST timezone is east of UTC.You need to use this only if daylight is nonzero.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">2<\/td>\n<td><strong>time.asctime([tupletime])<\/strong>Returns a readable 24-character string such as &#8216;Wed Feb 06 14:07:14 2019&#8217;. Takes a time tuple as parameter<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">3<\/td>\n<td><strong>time.clock( )<\/strong>Returns the current CPU time. Return value is a floating-point number of seconds. Based on performance,\u00a0 the value of time.clock is more useful than that of time.time().<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">4<\/td>\n<td><strong>time.ctime([secs])<\/strong>Similar to asctime(localtime(secs)) but without arguments is like asctime( )<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">5<\/td>\n<td><strong>time.gmtime([secs])<\/strong>Returns a time-tuple t with the UTC time.\u00a0Accepts an instant expressed in seconds since the epoch as parameter. Note : t.tm_isdst is always 0<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">6<\/td>\n<td><strong>time.localtime([secs])<\/strong>Returns a time-tuple t with the local time (t.tm_isdst is 0 or 1, depending on if DST applies to instant secs by local rules).\u00a0Takes an instant expressed in seconds since the epoch\u00a0 as parameter<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">7<\/td>\n<td><strong>time.mktime(tupletime)<\/strong>Returns a floating-point value with the instant expressed in seconds since the epoch. It takes an instant expressed as a time-tuple in local time and<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">8<\/td>\n<td><strong>time.sleep(secs)<\/strong>Use this to\u00a0 suspends the calling thread for the specified seconds.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">9<\/td>\n<td><strong>time.strftime(fmt[,tupletime])<\/strong>It returns a string representing the instant as given by string fmt.\u00a0Accepts an instant expressed as a time-tuple in local time<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">10<\/td>\n<td><strong>time.strptime(str,fmt=&#8217;%a %b %d %H:%M:%S %Y&#8217;)<\/strong>\u00a0Returns the instant in time-tuple format of a given string.\u00a0Parses the given str according to format string fmt<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">11<\/td>\n<td><strong>time.time( )<\/strong>You used this to get the current time instant, a floating-point number of seconds since the epoch.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">12<\/td>\n<td><strong>time.tzset()<\/strong>Resets the time conversion rules that is used by the library routines. The environment variable TZ shows how this is done.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t6\">6. The calendar Module<\/strong><\/h4>\n<p>Functions related to calendar are provided by the calendar module. For example,\u00a0 function to display a\u00a0 complete calendar for a particular month.<\/p>\n<p>By default, Monday is taken as the first day of the week. Then Sunday is regarded as the last day. However, the default behavior can be changed. To change is, use the calender.setfirstweekday() function.<\/p>\n<p>A list of functions available in the calendar module is given below:<\/p>\n<table class=\"table table-bordered\">\n<tbody>\n<tr>\n<th>SN.<\/th>\n<th>Function and brief description<\/th>\n<\/tr>\n<tr>\n<td class=\"ts\">1<\/td>\n<td><b>calendar.calendar(year,w=2,l=1,c=6)<\/b><\/p>\n<p>Returns a multi-line string with a calendar for year year formatted into three columns separated by c spaces. w specifies the width in characters of each date; each line has length 21*w+18+2*c. l is the number of lines for each week.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">2<\/td>\n<td><b>calendar.firstweekday( )<\/b><\/p>\n<p>Returns the current setting for the weekday that starts each week. By default, when calendar is first imported and used, it is 0, which means Monday.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">3<\/td>\n<td><b>calendar.isleap(year)<\/b><\/p>\n<p>Returns True if the specified year is a leap year. Otherwise false<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">4<\/td>\n<td><b>calendar.leapdays(y1,y2)<\/b><\/p>\n<p>Gives the total number of leap days in the years within given\u00a0 range(y1,y2).<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">5<\/td>\n<td><b>calendar.month(year,month,w=2,l=1)<\/b><\/p>\n<p>Returns a multi-line string with a calendar for the specified month of the year. One line per week plus two header lines. w is the number of character (width) of each date; each line has length 7*w+6. l is the number of lines for each week.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">6<\/td>\n<td><b>calendar.monthcalendar(year,month)<\/b><\/p>\n<p>Returns a list of lists of ints. Each sublist denotes a week. Days that are outside the given month month of the specified year are set to 0; days within the month are set to their day-of-month, 1 and up.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">7<\/td>\n<td><b>calendar.monthrange(year,month)<\/b><\/p>\n<p>Returns two values: code of the weekday for the first day of the specified month in year year and\u00a0 t number of days in the month. Weekday codes are by default 0 (Monday) to 6 (Sunday); month numbers are 1 to 12. 1 for January, 2 for February etc<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">8<\/td>\n<td><b>calendar.prcal(year,w=2,l=1,c=6)<\/b><\/p>\n<p>Similar to print calendar.calendar(year,w,l,c).<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">9<\/td>\n<td><b>calendar.prmonth(year,month,w=2,l=1)<\/b><\/p>\n<p>Similar to print calendar.month(year,month,w,l).<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">10<\/td>\n<td><b>calendar.setfirstweekday(weekday)<\/b><\/p>\n<p>Used to set the first day of each week to weekday code weekday. Weekday codes are 0 (Monday) to 6 (Sunday) by dafault<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">11<\/td>\n<td><b>calendar.timegm(tupletime)<\/b><\/p>\n<p>Gives the inverse of time.gmtime: takes a time instant as parameter in time-tuple form and returns the same instant as a floating-point number of seconds since the epoch.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">12<\/td>\n<td><b>calendar.weekday(year,month,day)<\/b><\/p>\n<p>Returns the weekday code for the given date.\u00a0 By default, weekday codes are 0 (Monday) to 6 (Sunday); month numbers are 1 (January) to 12 (December).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>We would cover date and time data type in Python. Then we learn how to convert date and time data. &nbsp; We would cover the &hellip; <\/p>\n","protected":false},"author":395,"featured_media":185,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[12],"class_list":["post-184","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-tutorials","tag-python-date-and-time"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python - Date and Time - Python Tutorials<\/title>\n<meta name=\"description\" content=\"You will learn about dates and times in Python. How to use the time and calendar modules and how how to format date and time data\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/python\/13-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 - Python Tutorials\" \/>\n<meta property=\"og:description\" content=\"You will learn about dates and times in Python. How to use the time and calendar modules and how how to format date and time data\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-06T22:17:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-07-26T09:09:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Date-and-Time-in-Python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1005\" \/>\n\t<meta property=\"og:image:height\" content=\"574\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Python &#8211; Date and Time\",\"datePublished\":\"2019-02-06T22:17:21+00:00\",\"dateModified\":\"2020-07-26T09:09:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/\"},\"wordCount\":1129,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Date-and-Time-in-Python.jpg\",\"keywords\":[\"Python - Date and Time\"],\"articleSection\":[\"Python Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/\",\"name\":\"Python - Date and Time - Python Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Date-and-Time-in-Python.jpg\",\"datePublished\":\"2019-02-06T22:17:21+00:00\",\"dateModified\":\"2020-07-26T09:09:42+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"description\":\"You will learn about dates and times in Python. How to use the time and calendar modules and how how to format date and time data\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Date-and-Time-in-Python.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Date-and-Time-in-Python.jpg\",\"width\":1005,\"height\":574,\"caption\":\"Date and Time in Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/13-python-date-and-time\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python &#8211; Date and Time\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/\",\"name\":\"Python Tutorials\",\"description\":\"Python Tutorial for Programming and Data Science\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python - Date and Time - Python Tutorials","description":"You will learn about dates and times in Python. How to use the time and calendar modules and how how to format date and time data","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:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/","og_locale":"en_US","og_type":"article","og_title":"Python - Date and Time - Python Tutorials","og_description":"You will learn about dates and times in Python. How to use the time and calendar modules and how how to format date and time data","og_url":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/","og_site_name":"Python Tutorials","article_published_time":"2019-02-06T22:17:21+00:00","article_modified_time":"2020-07-26T09:09:42+00:00","og_image":[{"width":1005,"height":574,"url":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Date-and-Time-in-Python.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Python &#8211; Date and Time","datePublished":"2019-02-06T22:17:21+00:00","dateModified":"2020-07-26T09:09:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/"},"wordCount":1129,"commentCount":1,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Date-and-Time-in-Python.jpg","keywords":["Python - Date and Time"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/","url":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/","name":"Python - Date and Time - Python Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Date-and-Time-in-Python.jpg","datePublished":"2019-02-06T22:17:21+00:00","dateModified":"2020-07-26T09:09:42+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"description":"You will learn about dates and times in Python. How to use the time and calendar modules and how how to format date and time data","breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Date-and-Time-in-Python.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Date-and-Time-in-Python.jpg","width":1005,"height":574,"caption":"Date and Time in Python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/python\/13-python-date-and-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/python\/"},{"@type":"ListItem","position":2,"name":"Python &#8211; Date and Time"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/python\/#website","url":"https:\/\/www.kindsonthegenius.com\/python\/","name":"Python Tutorials","description":"Python Tutorial for Programming and Data Science","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/python\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/comments?post=184"}],"version-history":[{"count":2,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":380,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/184\/revisions\/380"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/media\/185"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/media?parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/categories?post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/tags?post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}