Chapter Contents

Previous

Next
time

time



Return the Current Time

Portability: ISO/ANSI C conforming, UNIX compatible, POSIX.1 conforming


SYNOPSIS
DESCRIPTION
RETURN VALUE
DIAGNOSTICS
PORTABILITY
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <time.h>

time_t time(time_t *timep);


DESCRIPTION

time returns the number of seconds from the start of an implementation-defined era. If the timep pointer is not NULL , this value is also stored in the storage addressed by timep . The type of time and of the data referenced by its argument is time_t , declared in the header file <time.h> . This is a numeric type (implemented on the IBM 370 system as double ).


RETURN VALUE

time returns the approximate number of seconds since the start of the epoch. The 1970 default epoch starts at midnight GMT, Jan. 1, 1970, as required by the POSIX.2 standard. See Timing Functions for information on defining a different epoch.


DIAGNOSTICS

(time_t)-1 is returned if the time cannot be determined.


PORTABILITY

SAS/C defines the type time_t as double. Because most C implementations define time_t as a long integer, some applications assume this equivalence. Such applications will require modifications for use with SAS/C.


IMPLEMENTATION

time returns the contents of the 370 time-of-day clock after conversion to time_t format and adjustment for the epoch.


EXAMPLE

#include <time.h>

time_t before, after;
main()
{
   time(&before);          /* Get time before computation. */
   compute();
   time(&after);           /* Get time after computation.  */
   printf("Elapsed time for computation = %10.4f seconds\n",
           difftime(after, before));
}


RELATED FUNCTIONS

difftime


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.