Featured image of post How to output the current time in ISO8601 format in C++

How to output the current time in ISO8601 format in C++

Prerequisites

  • ISO C++ 20 Standard (/std:c++20)

Code

1
2
3
4
#include <chrono>
#include <format>

std::string datetime = std::format("{:%FT%TZ}", system_clock::now());

That’s how to output the current time in ISO8601 format in C++.

References

comments powered by Disqus