06# Working with local time and asctime Functions | Advance C Programming | C ProgrammingToturial

preview_player
Показать описание
#Local Time Function
The C library function struct tm *localtime(const time_t *timer) uses the time pointed by timer to fill a tm structure with the values that represent the corresponding local time. The value of timer is broken up into the structure tm and expressed in the local time zone.

Declaration
Following is the declaration for localtime() function.

struct tm *localtime(const time_t *timer)
Parameters
timer − This is the pointer to a time_t value representing a calendar time.

Return Value
This function returns a pointer to a tm structure

#asctime Functions
The C library function char *asctime(const struct tm *timeptr) returns a pointer to a string which represents the day and time of the structure struct timeptr.

Declaration
Following is the declaration for asctime() function.

char *asctime(const struct tm *timeptr)
Parameters
The timeptr is a pointer to tm structure that contains a calendar time broken down into its components as shown below −

struct tm {
int tm_sec; /* seconds, range 0 to 59 */
int tm_min; /* minutes, range 0 to 59 */
int tm_hour; /* hours, range 0 to 23 */
int tm_mday; /* day of the month, range 1 to 31 */
int tm_mon; /* month, range 0 to 11 */
int tm_year; /* The number of years since 1900 */
int tm_wday; /* day of the week, range 0 to 6 */
int tm_yday; /* day in the year, range 0 to 365 */
int tm_isdst; /* daylight saving time */
};

Return Value
This function returns a C string containing the date and time information in a human-readable format 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.
Рекомендации по теме