LabWindows/CVI

Content Type
Programming Language
Current manual

mktime

mktime

time_t mktime (struct tm *localTime);

Purpose

Converts a local date and time represented in a struct tm into a calendar time value. If the calendar time cannot be represented, the value -1 is returned. 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 calendar time is the number of seconds since January 1, 1900 Coordinated Universal Time (UTC), formerly known as Greenwich Mean Time (GMT).

Note Note  This function also fills in the tm_wday and tm_yday members of the time struct in localTime with the correct values, ignoring the original values. It adjusts the other fields if they are out of range.

Parameters

Output
Name Type Description
localTime struct tm Contains the local date and time that are converted into the appropriate calendar time. The local time entered must be the format defined in tm, which holds the components of the calendar time.

Note Note  The tm_wday and tm_yday members of this time struct are filled with the correct values, ignoring the original values. The other fields also are adjusted if they are out of range.

Return Value

Name Type Description
calendarTime time_t Contains the returned calendar time if the conversion was successful. If the calendar time cannot be represented, the function returns the value -1. The calendar time is the number of seconds since January 1, 1900 Coordinated Universal Time (UTC), formerly known as Greenwich Mean Time (GMT).

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Was this information helpful?