time64() — Determine Current Time
Format
#include <time.h>
time64_t time64(time64_t *timeptr);
Language Level
ANSI
Threadsafe
Yes
Description
The
time64()
function
determines the current calendar time, in seconds. Note: Calendar
time is the number of seconds that have elapsed since EPOCH, which
is 00:00:00, January 1, 1970 Universal Coordinate Time (UTC).
Return Value
The time64()
function
returns the current calendar time. The return value is also stored
in the location that is given by timeptr.
If timeptr is NULL, the return
value is not stored. If the calendar time is not available, the value (time64_t)(-1) is
returned.
Example
This example gets the time and assigns
it to ltime. The
ctime64()
function
then converts the number of seconds to the current date and time.
This example then prints a message giving the current time. #include <time.h>
#include <stdio.h>
int main(void)
{
time64_t ltime;
if (time64(<ime) == -1)
{
printf("Calendar time not available.\n");
exit(1);
}
printf("The time is %s", ctime64(<ime));
}
/****************** Output should be similar to: ****************
The time is Mon Mar 22 19:01:41 2004
*/
Related Information
- asctime() — Convert Time to Character String
- asctime_r() — Convert Time to Character String (Restartable)
- ctime() — Convert Time to Character String
- ctime64() — Convert Time to Character String
- ctime_r() — Convert Time to Character String (Restartable)
- ctime() — Convert Time to Character String
- gmtime() — Convert Time
- gmtime64() — Convert Time
- gmtime64_r() — Convert Time (Restartable)
- gmtime_r() — Convert Time (Restartable)
- localtime() — Convert Time
- localtime64() — Convert Time
- localtime64_r() — Convert Time (Restartable)
- localtime_r() — Convert Time (Restartable)
- mktime() — Convert Local Time
- mktime64() — Convert Local Time
- time() — Determine Current Time
- <time.h>