{"id":2551,"date":"2019-08-30T09:43:47","date_gmt":"2019-08-30T08:43:47","guid":{"rendered":"https:\/\/ridgesolutions.ie\/?p=2551"},"modified":"2019-08-30T10:14:13","modified_gmt":"2019-08-30T09:14:13","slug":"format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c","status":"publish","type":"post","link":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/","title":{"rendered":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++"},"content":{"rendered":"<p>A C++ function to format an std::time_point as an ISO 8601 string.<\/p>\n<p>The C++ std chrono stuff is very useful but a bit of a head-wreck!\u00a0 One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included.\u00a0 This sort of time resolution is often required for accurately time stamping machine vision images, especially when acquiring at\u00a0 high rates from multiple cameras &#8211; accurate timestamps allow you to compare images from different cameras that were taken at the &#8216;same time&#8217;.<\/p>\n<p>Anyway if you&#8217;re happy to wait for C++20 then you will have access to a format() function; but if you&#8217;re more eager to format your time strings now, then here is a function which may fit the bill, it (the function) has to jump through some hoops, but gets there in the end.<\/p>\n<p><strong>Note:<\/strong> This function uses the std::chrono::system_clock but it could be converted (or templated) for other std clocks..<\/p>\n<pre>\r\n\/\/  Licensed under the Apache License, Version 2.0 (the \"License\");\r\n\/\/   you may not use this file except in compliance with the License.\r\n\/\/   You may obtain a copy of the License at\r\n\/\/\r\n\/\/       http:\/\/www.apache.org\/licenses\/LICENSE-2.0\r\n\/\/\r\n\/\/   Unless required by applicable law or agreed to in writing, software\r\n\/\/   distributed under the License is distributed on an \"AS IS\" BASIS,\r\n\/\/   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n\/\/   See the License for the specific language governing permissions and\r\n\/\/   limitations under the License.\r\n\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/ Format an std::time_point as an ISO 8601 string with fractional seconds to 6\r\n\/\/ decimal places, e.g. 2014-08-30T08:18:51.867479\r\n\/\/ Warning will not work for any date\/times before the start of the UNIX epoch.\r\n\/\/\r\n\r\n#include <chrono>\r\n\r\ninline std::string to_iso_8601(std::chrono::time_point<std::chrono::system_clock> t) {\r\n\r\n\t\/\/ convert to time_t which will represent the number of\r\n\t\/\/ seconds since the UNIX epoch, UTC 00:00:00 Thursday, 1st. January 1970\r\n\tauto epoch_seconds = std::chrono::system_clock::to_time_t(t);\r\n\r\n\t\/\/ Format this as date time to seconds resolution\r\n\t\/\/ e.g. 2016-08-30T08:18:51\r\n\tstd::stringstream stream;\r\n\tstream << std::put_time(gmtime(&#038;epoch_seconds), \"%FT%T\");\r\n\r\n\t\/\/ If we now convert back to a time_point we will get the time truncated\r\n\t\/\/ to whole seconds \r\n\tauto truncated = std::chrono::system_clock::from_time_t(epoch_seconds);\r\n\r\n\t\/\/ Now we subtract this seconds count from the original time to\r\n\t\/\/ get the number of extra microseconds..\r\n\tauto delta_us = std::chrono::duration_cast<std::chrono::microseconds>(t - truncated).count();\r\n\r\n\t\/\/ And append this to the output stream as fractional seconds\r\n\t\/\/ e.g. 2016-08-30T08:18:51.867479\r\n\tstream << \".\" << std::fixed << std::setw(6) << std::setfill('0') << delta_us;\r\n\r\n\treturn stream.str();\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck!\u00a0 One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included.\u00a0 This [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[301],"tags":[],"class_list":["post-2551","post","type-post","status-publish","format-standard","hentry","category-by-kevin-godden"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck! One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included. This\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Kevin Godden\"\/>\n\t<meta name=\"google-site-verification\" content=\"Kyj52YLp6GOPA44PVBffo9fjW8rgWHYYRF0ZYjfy6ss\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Systems and Embedded Software Engineering, Ireland. | Some thoughts of a busy Computer Engineer\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++\" \/>\n\t\t<meta property=\"og:description\" content=\"A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck! One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included. This\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-08-30T08:43:47+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-08-30T09:14:13+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++\" \/>\n\t\t<meta name=\"twitter:description\" content=\"A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck! One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included. This\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#article\",\"name\":\"Format std::time_point in ISO 8601 format with fractional seconds \\\/ microseconds in C++\",\"headline\":\"Format std::time_point in ISO 8601 format with fractional seconds \\\/ microseconds in C++\",\"author\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/ridge_logo1.jpg\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#articleImage\",\"width\":400,\"height\":81},\"datePublished\":\"2019-08-30T09:43:47+00:00\",\"dateModified\":\"2019-08-30T10:14:13+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#webpage\"},\"articleSection\":\"By Ridge Solutions\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.ridgesolutions.ie\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/by-kevin-godden\\\/#listItem\",\"name\":\"By Ridge Solutions\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/by-kevin-godden\\\/#listItem\",\"position\":2,\"name\":\"By Ridge Solutions\",\"item\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/by-kevin-godden\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#listItem\",\"name\":\"Format std::time_point in ISO 8601 format with fractional seconds \\\/ microseconds in C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#listItem\",\"position\":3,\"name\":\"Format std::time_point in ISO 8601 format with fractional seconds \\\/ microseconds in C++\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/by-kevin-godden\\\/#listItem\",\"name\":\"By Ridge Solutions\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\",\"name\":\"Ridge Solutions, Software Development and Software Engineering, Ireland.\",\"description\":\"Some thoughts of a busy Computer Engineer\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/ridge_logo1.jpg\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#organizationLogo\",\"width\":400,\"height\":81},\"image\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/#author\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/\",\"name\":\"Kevin Godden\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d2833f41e59a25cf2a9741a05ec383bfdd278762a5e0798a90940e7ab0a107a2?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Kevin Godden\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#webpage\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/\",\"name\":\"Format std::time_point in ISO 8601 format with fractional seconds \\\/ microseconds in C++\",\"description\":\"A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck! One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \\\/ microseconds included. This\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2019\\\/08\\\/30\\\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/#author\"},\"datePublished\":\"2019-08-30T09:43:47+00:00\",\"dateModified\":\"2019-08-30T10:14:13+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#website\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/\",\"name\":\"Ridge Solutions, Software Development and Software Engineering, Ireland.\",\"description\":\"Some thoughts of a busy Computer Engineer\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++","description":"A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck! One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included. This","canonical_url":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"google-site-verification":"Kyj52YLp6GOPA44PVBffo9fjW8rgWHYYRF0ZYjfy6ss","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#article","name":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++","headline":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++","author":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/#author"},"publisher":{"@id":"https:\/\/www.ridgesolutions.ie\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/www.ridgesolutions.ie\/wp-content\/uploads\/2013\/09\/ridge_logo1.jpg","@id":"https:\/\/www.ridgesolutions.ie\/#articleImage","width":400,"height":81},"datePublished":"2019-08-30T09:43:47+00:00","dateModified":"2019-08-30T10:14:13+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#webpage"},"isPartOf":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#webpage"},"articleSection":"By Ridge Solutions"},{"@type":"BreadcrumbList","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie#listItem","position":1,"name":"Home","item":"https:\/\/www.ridgesolutions.ie","nextItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/by-kevin-godden\/#listItem","name":"By Ridge Solutions"}},{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/by-kevin-godden\/#listItem","position":2,"name":"By Ridge Solutions","item":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/by-kevin-godden\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#listItem","name":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#listItem","position":3,"name":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++","previousItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/by-kevin-godden\/#listItem","name":"By Ridge Solutions"}}]},{"@type":"Organization","@id":"https:\/\/www.ridgesolutions.ie\/#organization","name":"Ridge Solutions, Software Development and Software Engineering, Ireland.","description":"Some thoughts of a busy Computer Engineer","url":"https:\/\/www.ridgesolutions.ie\/","logo":{"@type":"ImageObject","url":"https:\/\/www.ridgesolutions.ie\/wp-content\/uploads\/2013\/09\/ridge_logo1.jpg","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#organizationLogo","width":400,"height":81},"image":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/#author","url":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/","name":"Kevin Godden","image":{"@type":"ImageObject","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d2833f41e59a25cf2a9741a05ec383bfdd278762a5e0798a90940e7ab0a107a2?s=96&d=mm&r=g","width":96,"height":96,"caption":"Kevin Godden"}},{"@type":"WebPage","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#webpage","url":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/","name":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++","description":"A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck! One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included. This","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.ridgesolutions.ie\/#website"},"breadcrumb":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/#breadcrumblist"},"author":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/#author"},"creator":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/#author"},"datePublished":"2019-08-30T09:43:47+00:00","dateModified":"2019-08-30T10:14:13+00:00"},{"@type":"WebSite","@id":"https:\/\/www.ridgesolutions.ie\/#website","url":"https:\/\/www.ridgesolutions.ie\/","name":"Ridge Solutions, Software Development and Software Engineering, Ireland.","description":"Some thoughts of a busy Computer Engineer","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.ridgesolutions.ie\/#organization"}}]},"og:locale":"en_US","og:site_name":"Systems and Embedded Software Engineering, Ireland. | Some thoughts of a busy Computer Engineer","og:type":"article","og:title":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++","og:description":"A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck! One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included. This","og:url":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/","article:published_time":"2019-08-30T08:43:47+00:00","article:modified_time":"2019-08-30T09:14:13+00:00","twitter:card":"summary","twitter:title":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++","twitter:description":"A C++ function to format an std::time_point as an ISO 8601 string. The C++ std chrono stuff is very useful but a bit of a head-wreck! One of the things I had problems with was how to take an std::time_point value and format it as a string with the fractional seconds \/ microseconds included. This"},"aioseo_meta_data":{"post_id":"2551","title":null,"description":null,"keywords":[{"label":"c++","value":"c++"},{"label":"chrono","value":"chrono"},{"label":"iso8601","value":"iso8601"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-09-13 11:19:05","updated":"2025-07-15 23:24:48","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.ridgesolutions.ie\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.ridgesolutions.ie\/index.php\/category\/by-kevin-godden\/\" title=\"By Ridge Solutions\">By Ridge Solutions<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tFormat std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.ridgesolutions.ie"},{"label":"By Ridge Solutions","link":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/by-kevin-godden\/"},{"label":"Format std::time_point in ISO 8601 format with fractional seconds \/ microseconds in C++","link":"https:\/\/www.ridgesolutions.ie\/index.php\/2019\/08\/30\/format-stdtime_point-in-iso-8601-format-with-fractional-seconds-microseconds-in-c\/"}],"_links":{"self":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts\/2551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/comments?post=2551"}],"version-history":[{"count":0,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts\/2551\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/media?parent=2551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/categories?post=2551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/tags?post=2551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}