> ~ Online tutorial

<time.h>
    The C & C++ programming languages, time.h (ctime is the recommended header file for C++ programs) is a header file defined in the C Standard Library to declare time and date functions that provide standardized access to time/date manipulation and formatting.
Functions:

char *asctime(const struct tm* tmptr)
 
Convert tm to a string in the format "Www Mmm dd hh:mm:ss yyyy", where Www is the weekday, Mmm the month in letters, dd the day of the month, hh:mm:ss the time, and yyyy the year. The string is followed by a newline and a terminating null character, containing a total of 26 characters. The string pointed at is statically allocated and shared by ctime and asctime functions. Each time one of these functions is called the contents of the string is overwritten.

clock_t clock(void)

Return number of clock ticks since process start.

char* ctime(const time_t* timer)

Convert time_t time value to string in the same format as asctime. The string pointed is statically allocated and shared by ctime and asctime functions. Each time one of these functions is called the content of the string is overwritten. ctime also uses internally the buffer used by gmtime and localtime as return value, so a call to this function will overwrite this.

double difftime(time_t timer2, time_t timer1)

Returns timer2 minus timer1 to give the difference in seconds between the two times.

struct tm* gmtime(const time_t* timer)

Convert a time_t value to a tm structure as UTC time. This structure is statically allocated and shared by gmtime, localtime and ctime functions. Each time one of these functions is called the content of the structure is overwritten.

struct tm* gmtime_r(const time_t* timer, struct tm* result)

Convert a time_t value to a tm structure as UTC time. The time is stored in the tm struct referred to by result. This function is the thread-safe version of gmtime.

struct tm* localtime(const time_t* timer)

Convert a time_t time value to a tm structure as local time (ie time adjusted for the local time zone and daylight savings). This structure is statically allocated and shared by gmtime, localtime and ctime functions. Each time one of these functions is called the content of the structure is overwritten.

time_t mktime(struct tm* ptm)

Convert tm to a time_t time value. Checks the members of the tm structure passed as parameter ptm adjusting the values if the ones provided are not in the possible range or they are incomplete or mistaken and then translates that structure to a time_t value that is returned. The original values of tm_wday and tm_yday members of ptm are ignored and filled with the correspondent ones to the calculated date. The range of tm_mday is not checked until tm_mon and tm_year are determined. On error, a -1 value is returned.

time_t time(time_t* timer)

Get the current time (number of seconds from the epoch) from the system clock. Stores that value in timer. If timer is null, the value is not stored, but it is still returned by the function.
size t strftime(char* s, size t n, const char* format, const struct tm* tptr)
Format tm into a date/time string.

char * strptime(const char* buf, const char* format, struct tm* tptr)

Scan values from buf string into tptr struct. On success it returns pointer to the character following the last character parsed. Otherwise it returns null.

time_t timegm(struct tm *brokentime)

timegm is functionally identical to mktime except it always takes the input values to be Coordinated Universal Time (UTC) regardless of any local time zone setting. Note that timegm is the inverse of gmtime.
Portability note: mktime is essentially universally available. timegm is rather rare. For the most portable (but non-thread safe) conversion from a UTC broken-down time to a simple time, set the TZ environment variable to UTC, call mktime, then set TZ back.

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: