{"id":1407,"date":"2023-08-24T15:01:05","date_gmt":"2023-08-24T14:01:05","guid":{"rendered":"https:\/\/ibex.tech\/c\/?p=1407"},"modified":"2023-08-25T17:51:22","modified_gmt":"2023-08-25T16:51:22","slug":"converting-datetime","status":"publish","type":"post","link":"https:\/\/ibex.tech\/c\/c\/datetime\/converting-datetime","title":{"rendered":"Converting DateTime"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Converting struct tm to time_t<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tstruct tm Tm1 = {0};\n\ttime_t Time1;\n\n\tTime1 = mktime(&amp;Tm1);\t\t\t\/\/Convert tm to time_t<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Convert UTC string to tm<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tstruct tm Tm1 = {0};\n\tchar TextBuffer&#91;80];\n\n\n\t\/\/Convert UTC string to tm\n\tif (strptime(\"2020-08-01 11:05:13\", \"%Y-%m-%d %H:%M:%S\", &amp;Tm1) == NULL)\t\t\/\/Convert the character string pointed to by buf to values which are stored in the tm structure pointed to by tm, using the format specified by format\n\t\tprintf(\"strptime Failed\\n\");\n\n\t\/\/Convert tm to string\n\tstrftime(TextBuffer, sizeof(TextBuffer), \"%Y-%m-%d %H:%M:%S\", &amp;Tm1);\n\tprintf(\"UTC: %s\\n\", TextBuffer);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Converting struct tm to time_t Convert UTC string to tm<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118],"tags":[],"class_list":["post-1407","post","type-post","status-publish","format-standard","hentry","category-datetime"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/1407","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=1407"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/1407\/revisions"}],"predecessor-version":[{"id":1478,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/1407\/revisions\/1478"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/media?parent=1407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/categories?post=1407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/tags?post=1407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}