How to get the current system time in the formate of hh:mm:ss.ssssss without the day and the month. and what about getting the microsecond in that form? regards
Asked
Active
Viewed 34 times
0
-
[`std::chrono::system_clock::now()`](https://en.cppreference.com/w/cpp/chrono/system_clock/now) with [`std::strftime()`](https://en.cppreference.com/w/cpp/chrono/c/strftime). See [How to convert std::chrono::time_point to string](https://stackoverflow.com/questions/34857119/). I don't think you can get microseconds with this, though. – Remy Lebeau Nov 20 '20 at 22:45
-
using fmt is an option too- `using namespace std::chrono;` `auto now = system_clock::to_time_t(system_clock::now());` `fmt::format("{:%Y_%m_%d}", fmt::localtime(now));` – BlueLightning42 Nov 20 '20 at 22:47