localtime
- Updated2023-02-21
- 2 minute(s) read
localtime
struct tm *localtime (const time_t *calendarTime);
Purpose
Takes a calendar time, breaks it into its component parts, adjusts it to the local time zone, and stores the result in a struct tm. Calendar time can be obtained by calling time.
![]() |
Note Per the C89 specification, this function and the gmtime function return a pointer to the same static struct tm structure. Using these functions in conjunction with each other might result in overwriting the previous value of the localTime parameter. For more information about the C89 specification, refer to an external C89 reference. |
The struct tm contains the following members:
- *tm_hour indicates the number of hours after midnight. Valid values range from 0 to 23.
- *tm_isdst indicates the daylight savings time status. The following values are valid:
- *<Positive numbers>—Daylight savings time is in effect.
- *0—Daylight savings time is not in effect.
- *<Negative numbers>—Daylight savings time status is unavailable.
- *tm_mday indicates the day of the month. Valid values range from 1 to 31, where 1 indicates the first day of the month.
- *tm_min indicates the number of minutes after the hour. Valid values range from 0 to 59.
- *tm_mon indicates the month. Valid values range from 0 to 11, where 0 is January.
- *tm_sec indicates the number of seconds after the minute. Valid values range from 0 to 59.
- *tm_wday indicates the day of the week. Valid values range from 0 to 6, where 0 is Sunday.
- *tm_yday indicates the day of the year. Valid values range from 0 to 365, where 0 is January 1.
- *tm_year indicates the number of years since 1900.
The function returns a pointer to the structure containing the local date and time.
Parameters
Input | ||
Name | Type | Description |
calendarTime | const time_t * | Contains the calendar time to be converted. This calendar time is broken into its constituent parts and converted into a struct tm containing the result. Calendar time can be obtained by calling time. |
Return Value
Name | Type | Description |
localTime | struct tm * | Contains a pointer to a struct tm containing the components of the local date and time. |
Additional Information
Library: ANSI C Library
Include file: ansi_c.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later