C++ 中获取纳秒精度的时间
Link Share :https://zhiqiang.org/coding/cpp-get-time-in-nanoseconds.html
- via RSS
主要函数是timespec_get
,可参考https://zh.cppreference.com/w/c/chrono/timespec_get。
#include <time.h>
std::string time_in_nanoseconds()
{
struct timespec ts;
timespec_get(&ts, TIME_UTC);
static char buff[64];
int end = strftime(buff, sizeof buff, "%Y-%m-%d %H:%M:%S", gmtime(&ts.tv_sec));
sprintf(buff + end, " %09ld", ts.tv_nsec);
return buff;
}
作者暂无likerid, 赞赏暂由本网站代持,当作者有likerid后会全部转账给作者(我们会尽力而为)。
Tips: Until now, everytime you want to store your article, we will help you store it in Filecoin network. In the future, you can store it in Filecoin network using your own filecoin.
Support author:
Author's Filecoin address:
Or you can use Likecoin to support author: