{"id":1429,"date":"2023-08-24T16:11:10","date_gmt":"2023-08-24T15:11:10","guid":{"rendered":"https:\/\/ibex.tech\/c\/?p=1429"},"modified":"2026-06-17T09:25:03","modified_gmt":"2026-06-17T08:25:03","slug":"struct-tm","status":"publish","type":"post","link":"https:\/\/ibex.tech\/c\/c\/datetime\/struct-tm","title":{"rendered":"struct tm"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Struct tm<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tstruct tm Tm1 = {0};\t\/\/&lt;&lt;The = {0} is really important to ensure the struct if properly initialised, you can sometimes get weird runtime issues if you don't do this\n\n\tTm1.tm_year = (2015 - 1900);\t\/\/years since 1900 (we must be >= 1970 for time_t based calcs)\n\tTm1.tm_mon = 1;\t\t\/\/months since January (0-11)\n\tTm1.tm_mday = 18;\n\tTm1.tm_hour = 12;\n\tTm1.tm_min = 03;\n\tTm1.tm_sec = 48;\n<\/code><\/pre>\n\n\n\n<p class=\"has-vivid-red-color has-text-color wp-block-paragraph\"><em><strong>Note:<\/strong><\/em><br><em><strong>tm_year is&nbsp;years since 1900!!<\/strong><\/em><br><em><strong>tm_month&nbsp;is&nbsp;months&nbsp;since January (0-11)!!<br>Note when converting to time_t your year must be &gt;= 1970 as time_t is usually based from 00:00, Jan 1 1970 UTC!<\/strong><\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Copy struct tm<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can just use a normal equals:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tstruct tm Tm1 = {0};\n\tstruct tm Tm2 = {0};\n\n\t\/\/...\n\n\tTm2 = Tm1;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Struct tm Note:tm_year is&nbsp;years since 1900!!tm_month&nbsp;is&nbsp;months&nbsp;since January (0-11)!!Note when converting to time_t your year must be &gt;= 1970 as time_t is usually based from 00:00, Jan 1 1970 UTC! Copy struct tm You can just use a normal equals:<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118],"tags":[],"class_list":["post-1429","post","type-post","status-publish","format-standard","hentry","category-datetime"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/1429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/comments?post=1429"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/1429\/revisions"}],"predecessor-version":[{"id":1615,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/1429\/revisions\/1615"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/media?parent=1429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/categories?post=1429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/tags?post=1429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}