Previous Page
Next Page


Calculates the difference between two arithmetic time values

#include <time.h>
double difftime ( time_t time2 , time_t time1  );

The difftime( ) function returns the difference between two time values, time2 - time1, as a number of seconds. While difftime( ) has the return type double, its arguments have the type time_t. The time_t type is usually, but not necessarily, defined as an integer type such as long or unsigned long.

A common way to obtain the argument values passed to difftime( ) is by successive calls to the time( ) function, which returns the current time as a single arithmetic value.


See the sample program for clock( ) in this chapter.

See Also

asctime( ), ctime( ), gmtime( ), localtime( ), mktime( ), strftime( ), time( )

Previous Page
Next Page