- 如何在 unix O/S 上确定机器时间(以秒为单位)?(我不能使用 'date +%s',它不是 POSIX)。
- 以秒为单位的日期和纪元时间存在哪些功能?
- 通过使用日期“+%format”如何从当前时间减去 1-2 小时?
问候
问候
试试中的time
功能time.h
。例如:
time_t the_time=time(NULL);
// the_time now contains the number of seconds since the epoch
要获得过去的时间,只需减去秒数。由于一小时有 3600 秒,要倒退一小时,只需减去 3600。