Name
ftime - Gets the current time.
Syntax
#include <sys/types.h>
#include <sys/timeb.h>
void ftime(timeptr)
struct timeb *timeptr;
Description
The ftime function gets the current time and stores it in
the structure pointed to by timeptr. The timeb structure is
defined in sys/timeb.h. It contains four fields, time,
millitm, timezone, and dstflag, which have the following
values:
Field Value
dstflag Nonzero if daylight saving time is
currently in effect for the local time
zone. (See tzset for an explanation of
how daylight saving time is
determined.)
millitm Fraction of a second in milliseconds.
time The time in seconds since 00:00:00
Greenwich mean time, January 1, 1970.
timezone The difference in minutes, moving
westward, between Greenwich mean time
and local time. The value of timezone
is set from the value of the global
variable timezone (see tzset).
Return Value
The ftime function gives values to the fields in the
structure pointed to by timeptr. It does not return a value.
See Also
asctime(S), ctime(S), gmtime(S), localtime(S), time(S),
tzset(S)
Example
#include <sys/types.h> #include <sys/timeb.h> #include
<stdio.h> #include <time.h>
main()
{
struct timeb timebuffer;
char *timeline;
ftime(&timebuffer);
timeline = ctime(&(timebuffer.time));
printf("The time is %.19s.%hu %s\n",timeline,
timebuffer.millitm, &timeline[20]);
}
Sample output:
The time is Wed Dec 04 17:58:29.420 1985
This program uses ftime to obtain the current time and then
stores this time in timebuffer.
(printed 6/18/89)