|
time |
#include <time.h>
time_t time(time_t *timer);
Description
Gets time of day.
time gives the current time, in seconds, elapsed since 00:00:00 GMT, January 1,
1970, and stores that value in the location pointed to by timer, provided that
timer is not a NULL pointer.
|
#include <time.h> |
|
ctime |
#include <time.h>
char *ctime(const time_t *time);
Description
Converts date and time to a string.
ctime
converts a time value pointed to by time (the value returned by the function
time) into a 26-character string in the following form, terminating with a
newline character and a null character:
Mon Nov 21 11:31:54 1983\n\0
All the fields have constant width.
|
#include <stdio.h> |
|
localtime |
#include <time.h>
struct tm *localtime(const time_t *timer);
Description
Converts date and time to a structure.
localtime
accepts the address of a value returned by time and returns a pointer to the
structure of type tm containing the time elements. It corrects for the time zone
and possible daylight saving time.
This is the tm structure declaration from
the time.h header file:
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
|
localtime example |
|
#include <time.h> |
|
difftime |
#include <time.h>
double difftime(time_t time2, time_t time1);
Description
Computes the difference between two times.
difftime calculates the elapsed time in seconds, from time1 to time2.
|
#include <time.h> |