C++ How do I convert a std::chrono::time_point to long and back

前端 未结 4 1614
深忆病人
深忆病人 2020-12-04 06:32

I need to convert std::chrono::time_point to and from a long type (integer 64 bits). I´m starting working with std::chrono ...

4条回答
  •  时光说笑
    2020-12-04 07:05

    as a single line:

    long value_ms = std::chrono::duration_cast(std::chrono::time_point_cast(std::chrono::high_resolution_clock::now()).time_since_epoch()).count();
    

提交回复
热议问题