
#include <time.h> double difftime(time_t time2, time_t time1);
difftime computes the difference time2 - time1 in seconds,
where time2 and time1 are values of type time_t (such as
those returned by the time function).
difftime returns the difference between the two times in seconds.
difftime is implemented as a macro. If its arguments are not of
type time_t, the results are not meaningful.
#include <time.h>
#include <stdio.h>
main()
{
double x;
time_t last_written; /* time data last written */
/* time(&last_written); */
/* if data are more than 1 week old */
if ((x = difftime(time(NULL), last_written)) > 7 * 86400)
puts("Warning: These data are obsolete");
else printf("Data was last accessed %lf seconds ago.n", x);
}
time
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.