The Open Group Base Specifications Issue 7
IEEE Std 1003.1-2008, 2016 Edition
Copyright © 2001-2016 The IEEE and The Open Group

NAME

gettimeofday - get the date and time

SYNOPSIS

[OB XSI] [Option Start] #include <sys/time.h>

int gettimeofday(struct timeval *restrict
tp, void *restrict tzp); [Option End]

DESCRIPTION

The gettimeofday() function shall obtain the current time, expressed as seconds and microseconds since the Epoch, and store it in the timeval structure pointed to by tp. The resolution of the system clock is unspecified.

If tzp is not a null pointer, the behavior is unspecified.

RETURN VALUE

The gettimeofday() function shall return 0 and no value shall be reserved to indicate an error.

ERRORS

No errors are defined.


The following sections are informative.

EXAMPLES

None.

APPLICATION USAGE

Applications should use the clock_gettime() function instead of the obsolescent gettimeofday() function.

RATIONALE

None.

FUTURE DIRECTIONS

The gettimeofday() function may be removed in a future version.

SEE ALSO

clock_getres, ctime

XBD <sys/time.h>

CHANGE HISTORY

First released in Issue 4, Version 2.

Issue 5

Moved from X/OPEN UNIX extension to BASE.

Issue 6

The DESCRIPTION is updated to refer to "seconds since the Epoch" rather than "seconds since 00:00:00 UTC (Coordinated Universal Time), January 1 1970" for consistency with other time functions.

The restrict keyword is added to the gettimeofday() prototype for alignment with the ISO/IEC 9899:1999 standard.

Issue 7

The gettimeofday() function is marked obsolescent.

End of informative text.

 

return to top of page

UNIX ® is a registered Trademark of The Open Group.
POSIX ® is a registered Trademark of The IEEE.
Copyright © 2001-2016 The IEEE and The Open Group, All Rights Reserved
[ Main Index | XBD | XSH | XCU | XRAT ]