I read whole info about boost::chrono and still didn`t get how to convert boost::chrono::system_clock to string in easy way. For example, I want to get current time and convert it to string in next format: hh:mm:ss. For example I wan receive smth like this - 24:55:03. I can receive current time in next way:
auto current_time = boost::chrono::system_clock::now()
How simply to format current_time to string. It sad but I can`t find any help in boost documentation and in google.
So boost::chrono
should be fully supported in C++11's std::chrono
.
Which I believe is now fully supported by Visual Studio 2013 and gcc 4.8?
Anyway you can print using: put_time
There are a tremendous number of format specifiers in the link, you can use those to customize the output to your needs.
It's important to note that put_time
is just a stream manipulator. If you need to get your time in a string
you'll need to use put_time
with a stringstream
.