cpp以毫秒级精度获取当前时刻的时间戳
首先获得当前时刻的时间点
std::chrono::time_point<std::chrono::system_clock, std::chrono::milliseconds>
tp = std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now());
再将时间点转换为时间戳形式
int timestamp = tp.time_since_epoch().count()
Reference
C++11获取时间戳和时间戳转日期(毫秒精度)_std::time_t-CSDN博客
C++ - 使用std::chrono获取当前秒级/毫秒级/微秒级/纳秒级时间戳_std获取当前时间-CSDN博客
时间仓促,如有错误欢迎指出,欢迎在评论区讨论,如对您有帮助还请点个推荐、关注支持一下
作者: pomolnc
出处: https://www.cnblogs.com/pomolnc/p/17787726.html
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文链接,否则保留追究法律责任的权利。
若内容有侵犯您权益的地方,请公告栏处联系本人,本人定积极配合处理解决。