How to get current timestamp in milliseconds since 1970 just the way Java gets

前端 未结 6 1035
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 11:42

In Java, we can use System.currentTimeMillis() to get the current timestamp in Milliseconds since epoch time which is -

the difference, m

6条回答
  •  余生分开走
    2020-11-27 11:54

    If you have access to the C++ 11 libraries, check out the std::chrono library. You can use it to get the milliseconds since the Unix Epoch like this:

    #include 
    
    // ...
    
    using namespace std::chrono;
    milliseconds ms = duration_cast< milliseconds >(
        system_clock::now().time_since_epoch()
    );
    

提交回复
热议问题