Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++;RFC3339使用std::chrono的毫秒时间戳 我创建了一个时间戳,包括毫秒和UTC,在C++中使用 STD::StROO #包括 #包括 #包括 使用名称空间std; 使用名称空间std::chrono; 现在输入字符串\u rfc3339(){ const auto now=系统时钟::now(); const auto millis=duration\u cast(now.time\u since\u epoch()).count()%1000; const auto c_now=系统时钟::到时间(now); 细流ss; ss_C++_Std_Chrono_Rfc3339 - Fatal编程技术网

C++;RFC3339使用std::chrono的毫秒时间戳 我创建了一个时间戳,包括毫秒和UTC,在C++中使用 STD::StROO #包括 #包括 #包括 使用名称空间std; 使用名称空间std::chrono; 现在输入字符串\u rfc3339(){ const auto now=系统时钟::now(); const auto millis=duration\u cast(now.time\u since\u epoch()).count()%1000; const auto c_now=系统时钟::到时间(now); 细流ss; ss

C++;RFC3339使用std::chrono的毫秒时间戳 我创建了一个时间戳,包括毫秒和UTC,在C++中使用 STD::StROO #包括 #包括 #包括 使用名称空间std; 使用名称空间std::chrono; 现在输入字符串\u rfc3339(){ const auto now=系统时钟::now(); const auto millis=duration\u cast(now.time\u since\u epoch()).count()%1000; const auto c_now=系统时钟::到时间(now); 细流ss; ss,c++,std,chrono,rfc3339,C++,Std,Chrono,Rfc3339,你也可以用减法来做: string now_rfc3339() { const auto now_ms = time_point_cast<milliseconds>(system_clock::now()); const auto now_s = time_point_cast<seconds>(now_ms); const auto millis = now_ms - now_s; const auto c_now = system_c

你也可以用减法来做:

string
now_rfc3339()
{
    const auto now_ms = time_point_cast<milliseconds>(system_clock::now());
    const auto now_s = time_point_cast<seconds>(now_ms);
    const auto millis = now_ms - now_s;
    const auto c_now = system_clock::to_time_t(now_s);

    stringstream ss;
    ss << put_time(gmtime(&c_now), "%FT%T")
       << '.' << setfill('0') << setw(3) << millis.count() << 'Z';
    return ss.str();
}
字符串
现在_rfc339()
{
const auto now_ms=time_point_cast(系统时钟::now());
const auto now_s=时间点施法(now_ms);
const auto millis=now_ms-now_s;
const auto c_now=系统时钟::到时间(now);
细流ss;

ss谢谢Howard,我已经偶然发现了你的日期库,它看起来非常有用!我以后会记住它。但是在这个项目中,只有一个地方我需要这种格式,所以我宁愿不包括外部来源。
string
now_rfc3339()
{
    return date::format("%FT%TZ", time_point_cast<milliseconds>(system_clock::now()));
}