Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      tm

      From cppreference.com
      <c‎ |chrono
       
       
      Date and time utilities
      Functions
      Time manipulation
      Format conversions
      (deprecated in C23)(C11)
      (deprecated in C23)(C11)
      Constants
      Types
      tm
       
      Defined in header<time.h>
      struct tm;

      Structure holding a calendar date and time broken down into its components.

      Contents

      [edit]Member objects

      int tm_sec
      seconds after the minute –[061](until C99)[060](since C99)[note 1]
      (public member object)
      int tm_min
      minutes after the hour –[059]
      (public member object)
      int tm_hour
      hours since midnight –[023]
      (public member object)
      int tm_mday
      day of the month –[131]
      (public member object)
      int tm_mon
      months since January –[011]
      (public member object)
      int tm_year
      years since 1900
      (public member object)
      int tm_wday
      days since Sunday –[06]
      (public member object)
      int tm_yday
      days since January 1 –[0365]
      (public member object)
      int tm_isdst
      Daylight Saving Time flag. The value is positive if DST is in effect, zero if not and negative if no information is available
      (public member object)
      [edit]Notes

      The Standard mandates only the presence of the aforementioned members in either order. The implementations usually add more data-members to this structure.

      1. Range allows for a positive leap second. Two leap seconds in the same minute are not allowed (the C89 range 0..61 was a defect)

      [edit]Example

      Run this code
      #include <stdio.h>#include <time.h> int main(void){struct tm start={.tm_year=2022-1900, .tm_mday=1};mktime(&start);printf("%s",asctime(&start));// note implicit trailing '\n'}

      Output:

      Sat Jan  1 00:00:00 2022

      [edit]References

      • C23 standard (ISO/IEC 9899:2024):
      • 7.27.1/3 Components of time (p: TBD)
      • C17 standard (ISO/IEC 9899:2018):
      • 7.27.1/3 Components of time (p: 284)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.27.1/3 Components of time (p: 388)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.23.1/3 Components of time (p: 338)
      • C89/C90 standard (ISO/IEC 9899:1990):
      • 4.12.1 Components of time

      [edit]See also

      converts time since epoch to calendar time expressed as local time
      (function)[edit]
      converts time since epoch to calendar time expressed as Coordinated Universal Time (UTC)
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/chrono/tm&oldid=172469"

      [8]ページ先頭

      ©2009-2025 Movatter.jp