#include <sys/timeb.h> int ftime (struct timeb *tp);
The ftime() function retrieves the current Coordinated Universal Time (UTC) and places it in timeb structure pointed to by tp.
None
0 | ftime() was
successful. |
-1 | ftime() was not successful. The errno variable is set to indicate the error. |
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.
[EINVAL] | An invalid parameter was found.
A parameter passed to this function is not valid. |
[EFAULT] | The address used for an argument is not correct.
In attempting to use an argument in a call, the system detected an address that is not valid. While attempting to access a parameter passed to this function, the system detected an address that is not valid. |
[EUNKNOWN] | Unknown system state.
The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation. |
None.
See Code disclaimer information for information pertaining to code examples.
The following example gets the current date and time:
#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
Top | Date and Time APIs | APIs by category |