文章目录
Linux系统中和时间相关的系统接口
提到Linux时间,首先先提一下Unix time,英文说明如下:
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT)
意思就是:距离1970年1月1日格林威治时间00:00:00的累计的秒数。在linux系统中使用一个long int整型数存放的。
1.1 Linux常见的几种存储时间的数据类型
// time_t的定义
typedef __time_t time_t;
__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
#define __TIME_T_TYPE __SYSCALL_SLONG_TYPE
/* X32 kernel interface is 64-bit. */
#if defined __x86_64__ && defined __ILP32__
# define __SYSCALL_SLONG_TYPE __SQUAD_TYPE
# define __SYSCALL_ULONG_TYPE __UQUAD_TYPE
#else
# define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE