{"id":15894,"date":"2020-11-01T23:19:19","date_gmt":"2020-11-02T07:19:19","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=15894"},"modified":"2023-12-01T04:03:55","modified_gmt":"2023-12-01T12:03:55","slug":"python-time","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-time\/","title":{"rendered":"How to Use the Python Time Module"},"content":{"rendered":"\n<p><em>The Python time module represents time-based objects in Python. Developers use time() function returns the current time as a UNIX timestamp. The ctime() function translates a UNIX timestamp into a standard year, month, day, and time format. <\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Working with time is an essential part of many programs. For instance, suppose you\u2019re building a sign-up form for a website. You may want to retrieve the current time so you know when a user signed up for your site.<\/p>\n\n\n\n<p>That\u2019s where the Python time module comes in. The time module allows you to work with time in your Python programs. You can perform actions like retrieving the current time and creating a pause in the program.\n\n<\/p>\n\n\n\n<p>This tutorial will discuss, with reference to examples, the basics of the Python time module and how to use it.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Importing the Python Time Module<\/h2>\n\n\n\n<p>The time module has a number of time-related functions you can implement in your Python programs. You can use the time module in all versions of Python.&nbsp;\n\n<\/p>\n\n\n\n<p>Before we discuss how to use the time module, we first need to import it into our program. We can do so using a <a href=\"https:\/\/careerkarma.com\/blog\/python-import\/\">Python import statement<\/a>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import time<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">time() Python Function<\/h2>\n\n\n\n<p>The Python <em>time()<\/em> function retrieves the current time. The time is represented as the number of seconds since January 1, 1970. This is the point at which UNIX time starts, also called the &#8220;epoch.&#8221;<\/p>\n\n\n\n<p>Suppose we want to retrieve the time at this moment. We could do so using this program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import time\n\ncurrent_time = time.time()\nprint(current_time)<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>1586944173.957986<\/pre><\/div>\n\n\n\n<p>Notice that our program did not return a regular time, such as 10:30 A.M. Our program returned a floating-point number (in other words, a decimal number).<\/p>\n\n\n\n<p>This floating-point number is the number of seconds since the epoch started. We printed the time to the console using a <a href=\"https:\/\/careerkarma.com\/blog\/python-print-without-new-line\/\">print statement<\/a>. <\/p>\n\n\n\n<p>In programming, epoch time is a standard way of representing time. The time module does not have to account for time zones.<\/p>\n\n\n\n<p>This is because epoch time only stores the number of seconds since the aforementioned date and time. No timezone data is stored, like Coordinated Universal Time, alongside an epoch value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Get Current Time Using ctime()<\/h2>\n\n\n\n<p>Epoch time is not readable to most humans. You can concert the time from epoch to local time using the Python <em>ctime()<\/em> function.<\/p>\n\n\n\n<p>The <em>ctime()<\/em> function accepts one argument. This argument is the number of seconds since the epoch started and returns a string with the local time. This value is based on the computer\u2019s time zone.<\/p>\n\n\n\n<p>Suppose we want to convert our previous epoch floating-point number into a timestamp. We could do so using this program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import time\n\nepoch_time = 1586944173.957986\nlocal_time = time.ctime(epoch_time)\n\nprint(&quot;The local time is:&quot;, local_time)<\/pre><\/div>\n\n\n\n<p>Our code returns the time:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>The local time is: Wed Apr 15 09:49:33 2020<\/pre><\/div>\n\n\n\n<p>First, we declared a <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">Python variable<\/a> called <em>epoch_time<\/em>. This variable stores our epoch timestamp.\n\n<\/p>\n\n\n\n<p>Then, we used <em>time.ctime()<\/em> to convert the timestamp into local time. On the next line of our code, we printed the statement <em>The local time is:<\/em>, followed by the local time. Also, the comma between <em>The local time is:<\/em> and the <em>local_time<\/em> variable adds in a space between the two values. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python time sleep Function<\/h2>\n\n\n\n<p>One of the most common functions in Python\u2019s time library is the <em>time.sleep()<\/em> function. <em>time.sleep()<\/em> suspends the execution of a program for a specified number of seconds.\n\n<\/p>\n\n\n\n<p>Suppose we want to print out the phrase \u201cLogging out \u2026 \u201d, then wait three seconds before printing \u201cLogout successful!\u201d to the console. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import time\n\nprint(&quot;Logging out \u2026 &quot;)\ntime.sleep(3)\nprint(&quot;Logout successful!&quot;)<\/pre><\/div>\n\n\n\n<p>Here\u2019s how our program works:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u201cLogging out \u2026 \u201d is printed to the console.<\/li><li>The program pauses for 3 seconds.<\/li><li>\u201cLogout successful!\u201d is printed to the console.<\/li><\/ul>\n\n\n\n<p>The <em>time.sleep()<\/em> function accepts floating-point (decimal) or integer (whole) number values. if you want a program to pause for 3.7 seconds, you can do so by specifying 3.7 as a parameter. In our above example, we specified 3.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python struct_time Object<\/h2>\n\n\n\n<p>The Python time library\u2019s <em>struct_time<\/em> odatetime bject structures non-epochal timestamps. The <em>struct_time<\/em> object is useful because it allows you to work with a standardized form when you\u2019re using timestamps.<\/p>\n\n\n\n<p>Here are the values the <em>struct_time<\/em> object can store:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>tm_year: year<\/li><li>tm_mon: month<\/li><li>tm_mday: day of the month<\/li><li>tm_hour: hour<\/li><li>tm_min: minute<\/li><li>tm_sec: second<\/li><li>tm_wday: day of the week (0 is Monday)<\/li><li>tm_yday: day of the year<\/li><li>tm_isdst: time in daylight savings time<\/li><\/ul>\n\n\n\n<p>We can access all of these attributes through a <em>struct_time<\/em> object. We employ <em>struct_time<\/em> objects in our examples below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using the Python structime_object<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Python time.localtime()<\/h3>\n\n\n\n<p>Now, suppose we want to convert epoch time to local time and have the outcome return a <em>struct_time<\/em> object. We could do so using either the <em>localtime()<\/em> or <em>gmtime()<\/em> functions.&nbsp;\n\n<\/p>\n\n\n\n<p>The <em>localtime()<\/em> function accepts an epoch time and returns a <em>struct_time<\/em> object.\n\n<\/p>\n\n\n\n<p>Suppose we want to get the current day of the week and minute of the hour. We could do so using this program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import time\n\ncurrent_time = time.localtime(1586944173.957986)\nprint(&quot;Day of the week:&quot;, current_time.tm_wday)\nprint(&quot;Minute of the hour:&quot;, current_time.tm_min)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Day of the week: 2\nMinute of the hour: 49<\/pre><\/div>\n\n\n\n<p>First, we imported the time library. Then, we used <em>localtime()<\/em> to convert our epoch timestamp from earlier to a <em>struct_time<\/em> object.\n\n<\/p>\n\n\n\n<p>On the next line, we printed the statement <em>Day of the week:<\/em> to the console. We then printed the day of the week (which is stored in the <em>tm_wday<\/em> value of our <em>current_time<\/em> object).<\/p>\n\n\n\n<p>Next, we printed the statement <em>Minute of the hour:<\/em> to the console. We followed this statement with the current minute of the hour (stored in the <em>tm_min<\/em> value of our <em>current_time<\/em> object).\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Python time.gmtime()<\/h3>\n\n\n\n<p>The <em>gmtime()<\/em> function works the same way as the <em>localtime()<\/em> function does, returning a <em>struct_time<\/em> object from an epoch time.\n\n<\/p>\n\n\n\n<p>Suppose we want to find out the month of the year and the day of the month. We could do so using this program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import time\n\ncurrent_time = time.gmtime(1586944173.957986)\nprint(&quot;Month of the year:&quot;, current_time.tm_mon)\nprint(&quot;Day of the month:&quot;, current_time.tm_mday)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Month of the year: 4\nDay of the month: 15<\/pre><\/div>\n\n\n\n<p>In our code, we used <em>gmtime()<\/em> instead of <em>localtime()<\/em> to generate a struct_time object. We assigned the value of the <em>gmtime()<\/em> method to the variable <em>current_time<\/em>.\n\n<\/p>\n\n\n\n<p>Next, we printed the <a href=\"https:\/\/careerkarma.com\/blog\/python-substring\/\">Python string<\/a> <em>Month of the year:<\/em> to the console, followed by the current month of the year. This value is stored in the <em>tm_mon<\/em> value in our <em>current_time<\/em> object.<\/p>\n\n\n\n<p>Then, we printed <em>Day of the month:<\/em> to the console, followed by the current day of the month. This value is in the <em>tm_mday<\/em> value in the <em>current_time<\/em> object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Python time.asctime()<\/h3>\n\n\n\n<p>The <em>asctime()<\/em> function convertsa <em>struct_time<\/em> object into a formatted string. Consider the following example: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import time\n\ncurrent_time = time.localtime(1586944173.957986)\nformatted_time = time.asctime(current_time)\n\nprint(&quot;The current time is:&quot;, formatted_time)<\/pre><\/div>\n\n\n\n<p>Our program returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>The current time is: Wed Apr 15 09:49:33 2020<\/pre><\/div>\n\n\n\n<p>In this example, we use the <em>localtime()<\/em> function to convert epoch time into a struct_time object. Then, we use <em>asctime()<\/em> to convert our struct_time object into a fully-formatted string representing the current time.<\/p>\n\n\n\n<p>This string is assigned to the variable <em>formatted_time<\/em>. Then, we print the statement <em>The current time is:<\/em>, followed by the formatted time.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">time.strftime()<\/h3>\n\n\n\n<p>The <code>strftime()<\/code> function formats the values in a <code>struct_time<\/code> object to a particular string.&nbsp;<\/p>\n\n\n\n<p>For instance, suppose we want to turn a <em>struct_time<\/em> object into a string with the following format: <em>MONTH\/DAY\/YEAR<\/em>. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import time\n\ncurrent_time = time.localtime()\nfinal_time = time.strftime(&quot;%m\/%d\/%Y&quot;, current_time)\n\nprint(final_time)<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>04\/15\/2020<\/pre><\/div>\n\n\n\n<p>We imported the time library. Then, we used <em>localtime()<\/em> to generate a <em>struct_time<\/em> object reflecting the current time. We then used <em>strftime()<\/em> to convert our <em>struct_time<\/em> object into a string that shows the month, day, and year. <\/p>\n\n\n\n<p>Lastly, we printed out the value of the <em>final_time<\/em> array. This array stores our formatted time.\n\n<\/p>\n\n\n\n<p>In this example:\n\n<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>%m denotes the month<\/li><li>%d denotes the day of the month<\/li><li>%Y denotes the year<\/li><\/ul>\n\n\n\n<p>Here are a few other values you could use with the <em>strftime<\/em> function:\n\n<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>%H denotes the hour of the day<\/li><li>%M denotes the minute of the hour<\/li><li>%S denotes the second of the minute<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The Python time module allows you to work with time in your Python code. The module comes with a number of different functions.<\/p>\n\n\n\n<p>You can use these to retrieve the current time, convert time between epoch time and more readable values, pause a program, format the current time, and perform other tasks.<\/p>\n\n\n\n<p>Read our guide on <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Code in Python<\/a> for tips and tricks on how to advance your knowledge of the Python programming language.<\/p>\n","protected":false},"excerpt":{"rendered":"The Python time module represents time-based objects in Python. Developers use time() function returns the current time as a UNIX timestamp. The ctime() function translates a UNIX timestamp into a standard year, month, day, and time format. Working with time is an essential part of many programs. For instance, suppose you\u2019re building a sign-up form&hellip;","protected":false},"author":240,"featured_media":15895,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-15894","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Use the Python Time Module: A Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The Python time module lets you work with time. On Career Karma, learn how to use the Python time module and its built-in functions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use the Python Time Module\" \/>\n<meta property=\"og:description\" content=\"The Python time module lets you work with time. On Career Karma, learn how to use the Python time module and its built-in functions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-time\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-02T07:19:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:03:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"How to Use the Python Time Module\",\"datePublished\":\"2020-11-02T07:19:19+00:00\",\"dateModified\":\"2023-12-01T12:03:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/\"},\"wordCount\":1375,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-time\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-time\/\",\"name\":\"How to Use the Python Time Module: A Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg\",\"datePublished\":\"2020-11-02T07:19:19+00:00\",\"dateModified\":\"2023-12-01T12:03:55+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The Python time module lets you work with time. On Career Karma, learn how to use the Python time module and its built-in functions.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-time\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-time\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/careerkarma.com\/blog\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Use the Python Time Module\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Use the Python Time Module: A Complete Guide | Career Karma","description":"The Python time module lets you work with time. On Career Karma, learn how to use the Python time module and its built-in functions.","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:\/\/careerkarma.com\/blog\/python-time\/","og_locale":"en_US","og_type":"article","og_title":"How to Use the Python Time Module","og_description":"The Python time module lets you work with time. On Career Karma, learn how to use the Python time module and its built-in functions.","og_url":"https:\/\/careerkarma.com\/blog\/python-time\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-11-02T07:19:19+00:00","article_modified_time":"2023-12-01T12:03:55+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-time\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-time\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"How to Use the Python Time Module","datePublished":"2020-11-02T07:19:19+00:00","dateModified":"2023-12-01T12:03:55+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-time\/"},"wordCount":1375,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-time\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-time\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-time\/","url":"https:\/\/careerkarma.com\/blog\/python-time\/","name":"How to Use the Python Time Module: A Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-time\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-time\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg","datePublished":"2020-11-02T07:19:19+00:00","dateModified":"2023-12-01T12:03:55+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The Python time module lets you work with time. On Career Karma, learn how to use the Python time module and its built-in functions.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-time\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-time\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-in-gray-shirt-sitting-on-bed-3954635.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"How to Use the Python Time Module"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/15894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=15894"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/15894\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/15895"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=15894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=15894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=15894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}