using date function in unix
- how can I determine machine time in seconds on unix O/S? (i can't use 'date +%s', it's not POSIX).
- what functions exist for 开发者_运维知识库date and epoch time in second?
- 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.
精彩评论