计算机纪元 时间戳
In C, how to get the epoch timestamp, the number of seconds passed since the epoch?
在C中 ,如何获取新纪元时间戳,即自新纪元以来经过的秒数?
In C, from man 7 time
:
在C中 ,距man 7 time
:
UNIX systems represent time in seconds since the Epoch, 1970-01-01
00:00:00 +0000 (UTC).自1970年1月1日以来,UNIX 系统以秒为单位表示时间
00:00:00 +0000(UTC)。A program can determine the calendar time using gettimeofday(2), which
returns time (in seconds and microseconds) that have elapsed since the
Epoch; time(2) provides similar information, but only with accuracy to
the nearest second.程序可以使用gettimeofday(2)确定日历时间,
返回自从开始到现在的时间(以秒和微秒为单位)
时代; time(2)提供类似的信息,但仅具有
最近的秒。
You can use the time()
library function to get the epoch timestamp:
您可以使用time()
库函数获取纪元时间戳:
On 32-bit POSIX systems:
在32位POSIX系统上:
fprintf(stdout, "%un", (unsigned)time(NULL));
On 64-bit POSIX systems:
在64位POSIX系统上:
fprintf(stdout, "%lun", (unsigned long)time(NULL));
翻译自: https://www.systutorials.com/how-to-get-the-epoch-timestamp-in-c/
计算机纪元 时间戳