Time and Date Functions
- Updated2023-02-21
- 2 minute(s) read
Time and Date Functions
The ANSI C time and date functions handle time and date operations. Included are functions to query for time, make time conversions, and format time strings.
The functions in the Time Conversion class use a struct tm, which 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.
time returns the number of seconds since Jan. 1, 1900.
mktime and localtime require time zone information to produce correct results. LabWindows/CVI obtains time zone information from the environment variable TZ, if it exists. The value of this variable has the format AAA[S]HH[:MM]BBB, where optional items are in square brackets.
The AAA and BBB fields specify the names of the standard and daylight savings time (DST) zones, respectively, such as EST for Eastern Standard Time and EDT for Eastern Daylight Time. The optional sign field S indicates whether the local time zone is to the west (+) or to the east (-) of UTC (Greenwich Mean Time). The hour field HH and the optional minutes field :MM specify the number of hours and minutes from UTC. For example, the string EST05EDT specifies the time zone information for the eastern part of the United States.