Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      time_t

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

      Real arithmetic type capable of representing times.

      Although not defined by the C standard, this is almost always an integral value holding the number of seconds (not counting leap seconds) since 00:00, Jan 1 1970 UTC, corresponding to POSIX time.

      Contents

      [edit]Notes

      The standard uses the termcalendar time when referring to a value of typetime_t.

      [edit]Example

      Show the start of the epoch.

      Run this code
      #include <stdio.h>#include <time.h>#include <stdint.h> int main(void){    time_t epoch=0;printf("%jd seconds since the epoch began\n",(intmax_t)epoch);printf("%s",asctime(gmtime(&epoch)));}

      Possible output:

      0 seconds since the epoch beganThu Jan  1 00:00:00 1970

      [edit]References

      • 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

      returns the current calendar time of the system as time since epoch
      (function)[edit]
      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/time_t&oldid=144874"

      [8]ページ先頭

      ©2009-2025 Movatter.jp