ftime
Go Up to sys\timeb.h Index
Header File
sys\timeb.h
Category
Time and Date Routines
Prototype
void ftime(struct timeb *buf)
Description
Stores current time in timeb structure.
On UNIX platforms ftime is available only on System V systems.
ftime determines the current time and fills in the fields in the timeb structure pointed to by buf. The timeb structure contains four fields: time, millitm, _timezone, and dstflag:
struct timeb { long time ; short millitm ; short _timezone ; short dstflag ; };
- time provides the time in seconds since 00:00:00 Greenwich mean time (GMT) January 1 1970.
- millitm is the fractional part of a second in milliseconds.
- _timezone is the difference in minutes between GMT and the local time. This value is computed going west from GMT. ftime gets this field from the global variable _timezone which is set by tzset.
- dstflag is set to nonzero if daylight saving time is taken into account during time calculations.
Note: ftime calls tzset. Therefore it isn't necessary to call tzset explicitly when you use ftime.
Return Value
None.
Example
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys\timeb.h> /* pacific standard & daylight savings */ char *tzstr = "TZ=PST8PDT"; int main(void) { struct timeb t; putenv(tzstr); tzset(); ftime(&t); printf("Seconds since 1/1/1970 GMT: %ld\n", t.time); printf("Thousandths of a second: %d\n", t.millitm); printf("Difference between local time and GMT: %d\n", t._timezone); printf("Daylight savings in effect (1) not (0): %d\n", t.dstflag); return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |