随笔分类 -  time

当前本地时间高精度
摘要:1 #include 2 void current_time() 3 { 4 // 当前时间点 5 std::chrono::system_clock::time_point t_now = 6 std::chrono::high_resolution_clock::now(); 7 // 转换精度到微秒级别 8 std::chr... 阅读全文
posted @ 2018-05-23 13:47 独孤酷酷 阅读(240) 评论(0) 推荐(0)
获取当前系统本地时间,精确到毫秒
摘要:1 #include 2 #include 3 4 char* cur_time_c(char strDateTime[32]) 5 { 6 struct timeb tp_cur; 7 ftime(&tp_cur); 8 9 struct tm btm; 10 11 #ifdef WIN32 12 localtime_s(&btm, ... 阅读全文
posted @ 2017-11-02 17:47 独孤酷酷 阅读(4299) 评论(0) 推荐(0)
时间处理函数
摘要:时间函数 阅读全文
posted @ 2017-09-14 10:25 独孤酷酷 阅读(182) 评论(0) 推荐(0)
gettimeofday() 获取系统时间,精确到微秒 这个似乎只能在linux 下用,不能在windows 下用
摘要:struct timeval{ long int tv_sec; // 秒数 同time(NULL) 的返回值 long int tv_usec; // 微秒数 10 的6次方 }; 1 struct timezone{ 2 int tz_minuteswest;/*格林威治时间往西方的时差*/ 3 int tz_dsttime;/*DST 时间的修... 阅读全文
posted @ 2015-05-08 22:53 独孤酷酷 阅读(3013) 评论(0) 推荐(0)
windows timeGetTime() 函数 获取系统从开机到现在的毫秒时间值
摘要:1 #include 2 #include 3 4 #pragma comment( lib,"winmm.lib" ) 5 6 int main() 7 { 8 DWORD msec = timeGetTime(); 9 std::cout << "msec = " << msec << std::endl; 10 11 return 0... 阅读全文
posted @ 2015-05-08 22:38 独孤酷酷 阅读(3725) 评论(0) 推荐(0)
ftime() 系统时间
摘要:ftime() 函数,这个函数是取系统的时间,精确到毫秒级别,它在windows 和linux 下都可用。所以我暂时是比较喜欢它的。 这个函数返回一个结构体,结构体中两个成员,其中time 成员,与函数 time(NULL) 返回的是等同的,用它可以配合localtime mktime ctime 阅读全文
posted @ 2015-05-08 22:36 独孤酷酷 阅读(5599) 评论(0) 推荐(0)