I am new to C++. I want to get current time in " HH:MM:ss:ms " format. How can I get it. I can get time using " %X " but in this case I need milliseconds. please help me.
...or
1) boost library time source
2) boost library time I/O either up to seconds (like with C), or use fractional seconds if you're okay with higher precision:
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include <locale>
#include <boost/date_time.hpp>
int main()
{
boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
std::cout.imbue(std::locale(std::cout.getloc(),
new boost::posix_time::time_facet(" %H:%M:%S:%f")));
std::cout << now << '\n';
}