|
|
HP-UX Reference > Ggettimeofday(2)HP-UX 11i Version 2: December 2007 Update |
|
NAMEgettimeofday() — get the date and time DESCRIPTIONThe gettimeofday() function obtains the current time, expressed as seconds and microseconds since Epoch, and stores it in the timeval structure pointed to by tp. The resolution of the system clock is one microsecond. PARAMETERSPrograms should use this time zone information only in the absence of the TZ environment variable.
time_t tv_sec /* Seconds. */ long tv_usec /* Microseconds. */
RETURN VALUEgettimeofday() returns the following values under HP-UX:
ERRORSIf gettimeofday() fails, errno is set to the following value under HP-UX:
EXAMPLESThe following HP-UX example calls gettimeofday() twice. It then computes the lapsed time between the calls in seconds and microseconds and stores the result in a timeval structure: struct timeval first, second, lapsed; struct timezone tzp; gettimeofday (&first, &tzp); /* lapsed time */ gettimeofday (&second, &tzp); if (first.tv_usec > second.tv_usec) { second.tv_usec += 1000000; second.tv_sec--; } lapsed.tv_usec = second.tv_usec - first.tv_usec; lapsed.tv_sec = second.tv_sec - first.tv_sec; |
|