linux 时间相关函数的用法
2013-03-12 15:40
260 查看
char *strptime(const char *buf,const
char *format, struct tm *tm);
// strftime
%a
星期几的简写形式
%A
星期几的全称
%b
月份的简写形式
%B
月份的全称
%c
日期和时间
%d
月份中的日期,0-31
%H
小时,00-23
%I
12进制小时钟点,01-12
%j
年份中的日期,001-366
%m
年份中的月份,01-12
%M
分,00-59
%p
上午或下午
%s
秒,00-60
%u
星期几,1-7
%w
星期几,0-6
%x
当地格式的日期
%X
当地格式的时间
%y
年份中的最后两位数,00-99
%Y
年
%Z
地理时区名称
linux 代码:
time_t
lt = time(NULL);
struct
tm *tmp = localtime(<);
char time_str[64];
char *tfomat = "%Y-%m-%d %H:%M:%S";
strftime(time_str, 64, tfomat, tmp);
printf(time_str);
cat /proc/uptime
2427774.85 2427035.31
2个数字的意义,第一个数值代表系统总的启动时间,第二个数值则代表系统空闲的时间,都是用秒来表示的。
char *format, struct tm *tm);
// strftime
%a
星期几的简写形式
%A
星期几的全称
%b
月份的简写形式
%B
月份的全称
%c
日期和时间
%d
月份中的日期,0-31
%H
小时,00-23
%I
12进制小时钟点,01-12
%j
年份中的日期,001-366
%m
年份中的月份,01-12
%M
分,00-59
%p
上午或下午
%s
秒,00-60
%u
星期几,1-7
%w
星期几,0-6
%x
当地格式的日期
%X
当地格式的时间
%y
年份中的最后两位数,00-99
%Y
年
%Z
地理时区名称
linux 代码:
time_t
lt = time(NULL);
struct
tm *tmp = localtime(<);
char time_str[64];
char *tfomat = "%Y-%m-%d %H:%M:%S";
strftime(time_str, 64, tfomat, tmp);
printf(time_str);
/proc/uptime的意义
cat /proc/uptime 2427774.85 2427035.31
2个数字的意义,第一个数值代表系统总的启动时间,第二个数值则代表系统空闲的时间,都是用秒来表示的。
相关文章推荐
- linux 下时间函数strftime()的用法
- linux 或c 时间相关处理类型和函数
- Linux系统中的计时机制及相关时间函数
- Linux下,和时间相关的几个函数
- Linux与时间相关的结构体及相关用法
- Linux中表示“时间”的结构体和相关函数相关
- Linux下的时间相关结构和函数
- linux中时间相关的函数介绍
- linux 上时间相关的函数 time ,_ftime , gettimeofday, clock_gettime
- linux-时间相关结构体和函数
- Linux系统中的计时机制及相关时间函数
- linux时间相关结构体和函数整理 (zz)
- linux时间相关结构体和函数整理【转载】
- linux时间相关结构体和函数整理
- 【转载】Linux时间相关结构与函数
- linux 时间编程相关函数
- linux时间相关结构体和函数整理
- linux的时间相关函数
- Linux与时间相关的结构体及相关用法
- linux下与时间相关的几个函数总结