开发者

using date function in unix

开发者 https://www.devze.com 2023-03-03 16:39 出处:网络
how can I determine machine time in seconds on unix O/S? (i can\'t use \'date +%s\', it\'s not POSIX).
  1. how can I determine machine time in seconds on unix O/S? (i can't use 'date +%s', it's not POSIX).
  2. what functions exist for 开发者_运维知识库date and epoch time in second?
  3. by using date "+%format" how can i subtract 1-2 hour from present hour?

Regards


Try the time function in time.h. For example:

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

To get a time in the past, just subtract the number of seconds. Since there are 3600 seconds in an hour, to go an hour back, just subtract 3600.

0

精彩评论

暂无评论...
验证码 换一张
取 消