#include <stdio.h>
#include <string.h>
#include <sys/time.h>  // gettimeofday
#include <sys/timeb.h> // ftime
#include <time.h>      // time clock_gettime
#include <unistd.h>long get_system_time_nanosecond();  // 纳秒
long get_system_time_microsecond(); // 微秒
long get_system_time_millisecond(); // 毫秒
long get_system_time_second();      // 秒long get_system_time_nanosecond()
{struct timespec timestamp = {};if (0 == clock_gettime(CLOCK_REALTIME, &timestamp))return timestamp.tv_sec * 1000000000 + timestamp.tv_nsec;elsereturn 0;
}long get_system_time_microsecond()
{struct timeval timestamp = {};if (0 == gettimeofday(&timestamp, NULL))return timestamp.tv_sec * 1000000 + timestamp.tv_usec;elsereturn 0;
}long get_system_time_millisecond()
{struct timeb timestamp = {};if (0 == ftime(&timestamp))return timestamp.time * 1000 + timestamp.millitm;elsereturn 0;
}long get_system_time_second()
{return time(NULL);
}int main(int argc, char const *argv[])
{long second = get_system_time_second();long millisecond = get_system_time_millisecond();long microsecond = get_system_time_microsecond();long nanosecond = get_system_time_nanosecond();printf("%ld\n", second);printf("%ld\n", millisecond);printf("%ld\n", microsecond);printf("%ld\n", nanosecond);return 0;
}

Linux C 获取系统时间秒/毫秒/微秒/纳秒相关推荐

  1. 秒 毫秒 微秒 纳秒 皮秒 飞秒

    millisecond              1ms (毫秒)       1毫秒=0.001秒=10-3秒 microsecond           1μs (微秒)         1微秒= ...

  2. 秒 毫秒 微秒 纳秒 皮秒。。时间单位换算

    1s=1000ms=1000000微秒=1000000000纳秒=1000000000000皮秒=10^15飞秒=10^18啊秒=10^21仄秒=10^24幺秒 1s=10^3ms(毫秒)=10^6μ ...

  3. 计算耗时为微秒的方法(包含:时/分/秒/毫秒/微秒/纳秒)

    计算耗时为微秒的方法1 #include<stdio.h> #include <windows.h> int main() {int a[10002];int i = 0;do ...

  4. 秒 毫秒 微秒 纳秒 Hz KHz MHz GHz

    1S = 1000 毫秒 m 1S = 1000000 微秒 u 1S = 1000000000 纳秒 n 1S = 1000000000000 皮秒 p ... 1Hz 电磁脉冲 每秒钟周期震动 1 ...

  5. 秒 毫秒 微秒 纳秒 皮秒

    0.000 001 微秒 = 1皮秒 0.001 微秒 = 1纳秒 微秒 1,000 微秒 = 1毫秒 1,000,000 微秒 = 1秒 1s = 1000ms 1ms = 1000μs 1μs = ...

  6. 秒,毫秒,微秒,纳秒,皮秒,飞秒

    转载于:https://www.cnblogs.com/zb-ml/p/8988940.html

  7. linux获得系统时间 c,linux c 获取系统时间

    #include main() { time_t timep; time (&timep); printf("%s",asctime(gmtime(&timep)) ...

  8. linux获得系统时间 c,linux c 获取系统时间的方法

    比如获取当前年份: /* 获取当前系统时间 暂时不使用 int iyear = 0; int sysyear = 0; time_t now; struct tm *timenow; time(&am ...

  9. linux下获取系统时间的方法

    可以用 localtime 函数分别获取年月日时分秒的数值. Linux下获得系统时间的C语言的实现方法: 1. 可以用 localtime 函数分别获取年月日时分秒的数值. #include< ...

最新文章

  1. 精简易懂,30 分钟学会 SVD 矩阵分解,很强!
  2. 《微服务:从设计到部署》中文版
  3. FreeSql (十九)多表查询
  4. 【软件测试】测试需求分析
  5. mysql中表的约束,主键外键唯一键
  6. PRML笔记 第一章 Introduction
  7. abaqus python二次开发攻略_Abaqus二次开发Python脚本二次开发
  8. 从软件工程的角度比较Swift、Go和Julia,我有了这些发现
  9. lua脚本之lua语言简介以及lua的安装
  10. 华三 h3c STP生成树保护配置
  11. 工行u盾显示316_工行银行网上交易老是提示插入u盾
  12. 微信公众平台:微信网页授权和微信支付
  13. 【Web】HTML基础——了解HMTL基本结构+常用标签的使用
  14. 网络附加存储(NAS)
  15. Jmeter读取CSV文件读取不到解决方法
  16. 纯css3卡通火龙果
  17. 一些学习经验总结和分享
  18. RabbitMQ的Qos
  19. 【ECCV2020】Spatio-Temporal Graph Transformer Networks for Pedestrian Trajectory Prediction
  20. MongoDB——聚合操作

热门文章

  1. 6.s081 lab 4
  2. Flash 动画制作
  3. ipad-mini 越狱总结
  4. 移动手机卡支持NFC支付 小米2A刷地铁体验
  5. linux 解压 文件 中文名乱码
  6. 浏览器集成德卡T10读卡器
  7. JAVA设计模式什么鬼(命令模式)——作者:凸凹里歐
  8. 用户画像:方法论与工程化解决方案
  9. 李祥对数值策划的定义
  10. 量子物理史话 第二章 乌云