在给定的203443
毫秒 持续时间内(这是3
分钟,23
秒和443
毫秒),例如
This took about' m 'minutes and' s 'seconds.
将产生以下内容 格式化输出:
This took about 3 minutes and 23 seconds.
从格式时间戳到当前日期时间不同。是否有任何C ++标准库(在C ++ 14下)或我可以遵循的解决方案。我是C ++的新手。
答案 0 :(得分:1)
#include <chrono>
#include <iostream>
int
main()
{
using namespace std::chrono;
auto d = 203443ms;
auto m = duration_cast<minutes>(d);
d -= m;
auto s = duration_cast<seconds>(d);
std::cout << "This took about " << m.count() << " minutes and "
<< s.count() << " seconds.\n";
}