ftime()--Get Date and Time


  Syntax
 #include <sys/timeb.h>

 int ftime (struct timeb *tp);

  Service Program Name: QWCTZUTC

  Default Public Authority: *USE

  Threadsafe: Yes

The ftime() function retrieves the current Coordinated Universal Time (UTC) and places it in timeb structure pointed to by tp.


Parameters

tp
(Output) A pointer to a timeb structure that contains the time in seconds and milliseconds since 1 January 1970, 00:00:00 UTC (epoch-1970), the local time zone (measured in minutes west of Greenwich), and a flag that, if nonzero, indicates Daylight Saving Time is currently in effect.


Authorities and Locks

None


Return Value



Error Conditions

If ftime() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.



Error Messages

None.


Related Information


Example

The following example gets the current date and time.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <sys/timeb.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char *argv[])
{
    struct timeb now;
    int rc;

    rc=ftime(&now);
    if(rc==0) {
        printf("ftime() successful.\n");
        printf("time = %u.%03u, "
               "timezone = %d, "
               "dstflag = %d\n",
                now.time, now.millitm,
                now.timezone,
                now.dstflag );
    }
    else {
        printf("ftime() failed, errno = %d\n",
                errno);
        return -1;
    }

    return 0;
}
Example Output:
ftime() successful.
time = 1019833362.226 timezone = 360, dstflag = 1


API introduced: V5R3

[ Back to top | Date and Time APIs | APIs by category ]