0
  1. 如何在 unix O/S 上确定机器时间(以秒为单位)?(我不能使用 'date +%s',它不是 POSIX)。
  2. 以秒为单位的日期和纪元时间存在哪些功能?
  3. 通过使用日期“+%format”如何从当前时间减去 1-2 小时?

问候

4

1 回答 1

0

试试中的time功能time.h。例如:

time_t the_time=time(NULL);
// the_time now contains the number of seconds since the epoch

要获得过去的时间,只需减去秒数。由于一小时有 3600 秒,要倒退一小时,只需减去 3600。

于 2011-05-09T06:20:23.387 回答