{"id":3302,"date":"2020-07-23T16:31:41","date_gmt":"2020-07-23T16:31:41","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=3302"},"modified":"2020-07-23T18:17:01","modified_gmt":"2020-07-23T18:17:01","slug":"date-and-time-filename","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/strings\/stringstream\/examples\/date-and-time-filename","title":{"rendered":"Date and Time"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">yyyymmddhhmmss.bin filename<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tstringstream FilePath;\n\tFilePath &lt;&lt; \"\/home\/pi\/myfolder\/\";\n\tFilePath &lt;&lt; setfill('0') &lt;&lt; setw(4) &lt;&lt; (int)(current_date_time.tm_year + 1900);\n\tFilePath &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)(current_date_time.tm_mon + 1);\n\tFilePath &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)current_date_time.tm_mday;\n\tFilePath &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)current_date_time.tm_hour;\n\tFilePath &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)current_date_time.tm_min;\n\tFilePath &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)current_date_time.tm_sec;\n\tFilePath &lt;&lt; \".bin\";<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">yyyy-mm-ddThh:mm:ss UTC timestamp<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tstringstream ss1;\n\tss1 &lt;&lt; setfill('0') &lt;&lt; setw(4) &lt;&lt; (int)(current_date_time.tm_year + 1900) &lt;&lt; \"-\";\n\tss1 &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)(current_date_time.tm_mon + 1) &lt;&lt; \"-\";\n\tss1 &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)current_date_time.tm_mday &lt;&lt; \"T\";\n\tss1 &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)current_date_time.tm_hour &lt;&lt; \":\";\n\tss1 &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)current_date_time.tm_min &lt;&lt; \":\";\n\tss1 &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; (int)current_date_time.tm_sec;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>yyyymmddhhmmss.bin filename yyyy-mm-ddThh:mm:ss UTC timestamp<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[157],"tags":[],"class_list":["post-3302","post","type-post","status-publish","format-standard","hentry","category-examples"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=3302"}],"version-history":[{"count":4,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3302\/revisions"}],"predecessor-version":[{"id":3306,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3302\/revisions\/3306"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=3302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=3302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=3302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}