#include <sys/time.h>
|
int
gettimeofday (struct timeval *tp, struct timezone *tzp); |
The structures pointed to by tp and tzp are defined in
#include <sys/time.h> as:
struct timeval { long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */ }; struct timezone { int tz_minuteswest; /* minutes west of Greenwich */ int tz_dsttime; /* type of dst correction */ }; The timezone structure indicates the local time zone (measured in minutes of time westward from Greenwich), and a flag that, if nonzero, indicates that Daylight Saving time applies locally during the appropriate part of the year. |
#include <stdio.h> #include <sys/time.h> int main() { struct timeval *tv; struct timezone *tz; int i = gettimeofday(tv, tz); printf("tv: %d, %d\n", tv->tv_sec, tv->tv_usec); printf("tz: %d, %d\n", tz->tz_minuteswest, tz->tz_dsttime); return 0; }
Output
tv: 1474660693, -326937770 tz: 7804688, 3
© 2005-2007 Nokia |