【发布时间】:2011-08-21 10:49:08
【问题描述】:
- 如何在 unix O/S 上确定机器时间(以秒为单位)? (我不能使用 'date +%s',它不是 POSIX)。
- 以秒为单位的日期和纪元时间存在哪些函数?
- 如何使用日期“+%format”从当前时间减去 1-2 小时?
问候
【问题讨论】:
-
看起来像 stackoverflow.com/questions/2445198 的副本
标签: epoch
问候
【问题讨论】:
标签: epoch
试试the time function in time.h。例如:
time_t the_time=time(NULL);
// the_time now contains the number of seconds since the epoch
要获得过去的时间,只需减去秒数。由于一小时有 3600 秒,要倒退一小时,只需减去 3600。
【讨论】:
date +%s 有什么问题;我使用的是 Mac OS X,它在这里工作。
date +%s。