.TH difftime() "" "" "Time Function (libc)"
.PC "Calculate difference between two times"
.B "#include <time.h>"
\fBdouble difftime(\fInewtime\^\fB, \fIoldtime\^\fB)\fR
\fBtime_t \fInewtime\^\fB, \fIoldtime\^\fB;\fR
.PP
.II "time^calculate difference between two times"
.B difftime()
subtracts
.I oldtime
from
.IR newtime ,
and returns the difference in seconds.
Both arguments are of type
.BR time_t ,
which is defined in the header
.BR time.h .
.SH Example
This example uses
.B difftime()
to show an arbitrary time difference.
.DM
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
.DE
.DM
main()
{
	time_t	t1, t2;
.DE
.DM
	time(&t1);
	printf("Press enter when you feel like it.\en");
	getchar();
	time(&t2);
.DE
.DM
	printf("You waited %f seconds\en", difftime(t2, t1));
	return(EXIT_SUCCESS);
}
.DE
.SH "See Also"
.Xr "clock()," clock
.Xr "libc," libc
.Xr "mktime()," mktime
.Xr "time [overview]" time.a
.br
\*(AS, \(sc7.12.2.2
