📜  c++ 获取时间 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:52.783000             🧑  作者: Mango

代码示例4
#include 

// Get the time since epoch (realtime clock), in milliseconds
int64_t getCurrentMSinceEpoch()
{
    return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count();
}

// Get the time since started, in milliseconds
// Better for time difference because it's faster than system_clock
int64_t getTimeMS()
{
    return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count();
}