0

At the moment I am getting the date and time in the following way:

 std::string isoString = boost::posix_time::to_iso_string(boost::posix_time::second_clock::universal_time());
 std::string date = isoString.substr(0,8);
 std::string time = isoString.substr(9,16); 

Problem: The milliseconds are missing and I need this information. How can I obtain the time with milliseconds?

4

3 に答える 3

2

使用できますboost::posix_time::microsec_clock

 std::string isoString = boost::posix_time::to_iso_string(boost::posix_time::microsec_clock::universal_time());
 std::string date = isoString.substr(0,8);
 std::string time = isoString.substr(9,20); 
于 2013-06-17T08:27:47.453 に答える
1

boost::posix_time::microsec_clockを使用する必要があります

于 2013-06-17T08:27:42.923 に答える
1

なぜ C++11 ではないのですか?

long long timestamp()
{
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
}
于 2013-06-17T08:44:16.657 に答える