[5]Linux时间编程
来源:互联网 发布:java的可变参数 编辑:程序博客网 时间:2024/06/05 07:20
1.1 获取日历时间
#include <time.h>time_t time(time_t *calptr);//返回距计算机元年的秒数#define time_t long
1.2 获取格林威治时间
#include <time.h> struct tm *gmtime(const time_t *calptr);//获取世界标准时间UTCstruct tm { int tm_sec; /* seconds after the minute: [0 - 60] */ int tm_min; /* minutes after the hour: [0 - 59] */ int tm_hour; /* hours after midnight: [0 - 23] */ int tm_mday; /* day of the month: [1 - 31] */ int tm_mon; /* months since January: [0 - 11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday: [0 - 6] */ int tm_yday; /* days since January 1: [0 - 365] */ int tm_isdst; /* daylight saving time flag: <0, 0, >0 */ // 以下两个字段在有些版本中是存在的,使用时需要查看对应的头文件确认 long int tm_gmtoff; /* Seconds east of UTC. */ const char *tm_zone; /* Timezone abbreviation. */ };
1.3 获取本地时间
#include <time.h>struct tm *localtime(const time_t *calptr);//获取本地时间
1.4 以字符串方式显示时间
#include <time.h>char *asctime(const struct tm *tmptr);//获取时间对应的字符串表示形式
1.5 获取高精度时间
#include<sys/time.h>int gettimeofday(struct timeval*tv,struct timezone *tz);//获取高精度的时间struct timeval{ long tv_sec;/*秒*/ long tv_usec;/*微妙*/};
来自国嵌【2014】应用程序开发
0 0
- [5]Linux时间编程
- linux--时间编程(5)
- linux下时间编程
- linux历程--时间编程
- Linux时间编程
- Linux应用 - 时间编程
- linux 时间编程
- linux时间编程
- linux时间编程
- Linux时间编程
- Study Linux - 时间编程
- Linux时间编程
- linux下时间编程
- linux时间编程
- Linux时间编程
- Linux编程---时间相关
- Linux时间编程
- linux时间编程
- Class.forName new 和newInstance
- java: Random 随机数组
- 191. Number of 1 Bits
- nodejs开发微博网站(二)--mongoDB数据库
- 3D游戏引擎系列二
- [5]Linux时间编程
- 捕捉Java的异常Stacktrace
- Frogger
- 关于HTTPS一篇文章就够了
- 洛谷 1226_取余运算||快速幂_快速幂
- Mac 安装opencv(for java)
- LoRaWAN介绍20 中国地区
- HTML5新增的标签和属性归纳
- 深度学习研究和进展