| United States-English |
|
|
|
![]() |
HP-UX Reference (Volume 5 of 9): Section 2: System Calls > ggettimeofday(2) |
|
NAMEgettimeofday — get the date and time DESCRIPTIONThe gettimeofday() function obtains the current time, expressed as seconds and microseconds since 00:00 Coordinated Universal Time (UTC), January 1, 1970, and stores 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 application is not a UNIX-conforming application. See the HP-UX EXTENSIONS section for treatment of a non-null pointer for the tzp argument. RETURN VALUEThe gettimeofday() function returns 0 and no value is reserved to indicate an error. See the HP-UX EXTENSIONS section for function return values under HP-UX. DESCRIPTIONWhen gettimeofday() is called under HP-UX, extensions apply to the time zone parameter, the return value, and errors. If the tzp parameter is not a null pointer, it is interpreted as a pointer to a struct timezone under HP-UX. The struct timezone has the following fields:
Programs should use this time zone information only in the absence of the TZ environment variable. RETURN VALUEgettimeofday() return 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; |
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||