首页 > 编程语言 >c++获取当前时间chrono

c++获取当前时间chrono

时间:2023-02-17 10:36:20浏览次数:39  
标签:chrono point long tpMicro 获取 c++ time 微秒

点击查看代码
long long get_cur_time(){
    // 获取操作系统当前时间点(精确到微秒)
    chrono::time_point<chrono::system_clock, chrono::microseconds> tpMicro
            = chrono::time_point_cast<chrono::microseconds>(chrono::system_clock::now());
    // (微秒精度的)时间点 => (微秒精度的)时间戳
    time_t totalMicroSeconds = tpMicro.time_since_epoch().count();

    long long currentTime = ((long long)totalMicroSeconds)/1000;

    return currentTime;
}

标签:chrono,point,long,tpMicro,获取,c++,time,微秒
From: https://www.cnblogs.com/52ld/p/17129219.html

相关文章