{"id":5057,"date":"2022-12-20T18:37:05","date_gmt":"2022-12-20T21:37:05","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/mktime-man3p\/"},"modified":"2022-12-20T18:37:05","modified_gmt":"2022-12-20T21:37:05","slug":"mktime-man3p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/mktime-man3p\/","title":{"rendered":"MKTIME (man3p)"},"content":{"rendered":"<h1 align=\"center\">MKTIME<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ERRORS\">ERRORS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">mktime \u2014 convert broken-down time into time since the Epoch<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">#include <time.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">time_t mktime(struct tm *<i>timeptr<\/i>);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The functionality described on this reference page is aligned with the ISO\u00a0C standard. Any conflict between the requirements described here and the ISO\u00a0C standard is unintentional. This volume of POSIX.1-2017 defers to the ISO\u00a0C standard.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>mktime<\/i>() function shall convert the broken-down time, expressed as local time, in the structure pointed to by <i>timeptr<\/i>, into a time since the Epoch value with the same encoding as that of the values returned by <i>time<\/i>(). The original values of the <i>tm_wday<\/i> and <i>tm_yday<\/i> components of the structure shall be ignored, and the original values of the other components shall not be restricted to the ranges described in <i><time.h><\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A positive or 0 value for <i>tm_isdst<\/i> shall cause <i>mktime<\/i>() to presume initially that Daylight Savings Time, respectively, is or is not in effect for the specified time. A negative value for <i>tm_isdst<\/i> shall cause <i>mktime<\/i>() to attempt to determine whether Daylight Savings Time is in effect for the specified time.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Local timezone information shall be set as though <i>mktime<\/i>() called <i>tzset<\/i>().<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The relationship between the <b>tm<\/b> structure (defined in the <i><time.h><\/i> header) and the time in seconds since the Epoch is that the result shall be as specified in the expression given in the definition of seconds since the Epoch (see the Base Definitions volume of POSIX.1-2017, <i>Section 4.16<\/i>, <i>Seconds Since the Epoch<\/i>) corrected for timezone and any seasonal time adjustments, where the names other than <i>tm_yday<\/i> in the structure and in the expression correspond, and the <i>tm_yday<\/i> value used in the expression is the day of the year from 0 to 365 inclusive, calculated from the other <b>tm<\/b> structure members specified in <i><time.h><\/i> (excluding <i>tm_wday<\/i>).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Upon successful completion, the values of the <i>tm_wday<\/i> and <i>tm_yday<\/i> components of the structure shall be set appropriately, and the other components shall be set to represent the specified time since the Epoch, but with their values forced to the ranges indicated in the <i><time.h><\/i> entry; the final value of <i>tm_mday<\/i> shall not be set until <i>tm_mon<\/i> and <i>tm_year<\/i> are determined.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>mktime<\/i>() function shall return the specified time since the Epoch encoded as a value of type <b>time_t<\/b>. If the time since the Epoch cannot be represented, the function shall return the value (<b>time_t<\/b>)\u22121 and set <i>errno<\/i> to indicate the error.<\/p>\n<h2>ERRORS <a name=\"ERRORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>mktime<\/i>() function shall fail if: <b><br \/> EOVERFLOW<\/b><\/p>\n<p style=\"margin-left:22%;\">The result cannot be represented.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">What day of the week is July 4, 2001?<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <stdio.h> <br \/> #include <time.h><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">struct tm time_str;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">char daybuf[20];<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">int main(void) <br \/> { <br \/> time_str.tm_year = 2001 \u2014 1900; <br \/> time_str.tm_mon = 7 \u2014 1; <br \/> time_str.tm_mday = 4; <br \/> time_str.tm_hour = 0; <br \/> time_str.tm_min = 0; <br \/> time_str.tm_sec = 1; <br \/> time_str.tm_isdst = -1; <br \/> if (mktime(&#038;time_str) == -1) <br \/> (void)puts(&#8220;-unknown-&#8220;); <br \/> else { <br \/> (void)strftime(daybuf, sizeof(daybuf), &#8220;%A&#8221;, &#038;time_str); <br \/> (void)puts(daybuf); <br \/> } <br \/> return 0; <br \/> }<\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>asctime<\/i>(), <i>clock<\/i>(), <i>ctime<\/i>(), <i>difftime<\/i>(), <i>gmtime<\/i>(), <i>localtime<\/i>(), <i>strftime<\/i>(), <i>strptime<\/i>(), <i>time<\/i>(), <i>tzset<\/i>(), <i>utime<\/i>()<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The Base Definitions volume of POSIX.1-2017, <i>Section 4.16<\/i>, <i>Seconds Since the Epoch<\/i>, <b><time.h><\/b><\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http:\/\/www.opengroup.org\/unix\/online.html .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  mktime \u2014 convert broken-down time into time since the Epoch <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3779,1],"tags":[1594,1951],"class_list":["post-5057","post","type-post","status-publish","format-standard","hentry","category-3pm-perl-llamadas-de-bibliotecas","category-sin-categoria","tag-man3p","tag-mktime"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=5057"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5057\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=5057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=5057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=5057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}