time64() — Determine Current Time

Format

#include <time.h>
time64_t time64(time64_t *timeptr);

Language Level: ILE C Extension.

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 (time_t)(-1) is returned.

Example that uses time64()

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(&ltime) == -1)
{
   printf("Calendar time not available.\n");
   exit(1);
}
   printf("The time is %s", ctime64(&ltime));
}
 
/******************  Output should be similar to:  ****************
 
The time is Mon Mar 22 19:01:41 2004
*/

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]