{
    "mode": "pydoc",
    "parameter": "time",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/time/json",
    "generated": "2026-06-02T15:50:23Z",
    "sections": {
        "NAME": {
            "content": "time - This module provides various functions to manipulate time values.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "There are two standard representations of time.  One is the number\nof seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer\nor a floating point number (to represent fractions of seconds).\nThe Epoch is system-defined; on Unix, it is generally January 1st, 1970.\nThe actual value can be retrieved by calling gmtime(0).\n\nThe other representation is a tuple of 9 integers giving local time.\nThe tuple items are:\nyear (including century, e.g. 1998)\nmonth (1-12)\nday (1-31)\nhours (0-23)\nminutes (0-59)\nseconds (0-59)\nweekday (0-6, Monday is 0)\nJulian day (day in the year, 1-366)\nDST (Daylight Savings Time) flag (-1, 0 or 1)\nIf the DST flag is 0, the time is given in the regular time zone;\nif it is 1, the time is given in the DST time zone;\nif it is -1, mktime() should guess based on the date and time.\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.tuple(builtins.object)\nstructtime\n",
            "subsections": [
                {
                    "name": "class struct_time",
                    "content": "|  structtime(iterable=(), /)\n|\n|  The time value as returned by gmtime(), localtime(), and strptime(), and\n|  accepted by asctime(), mktime() and strftime().  May be considered as a\n|  sequence of 9 integers.\n|\n|  Note that several fields' values are not the same as those defined by\n|  the C language standard for struct tm.  For example, the value of the\n|  field tmyear is the actual year, not year - 1900.  See individual\n|  fields' descriptions for details.\n|\n|  Method resolution order:\n|      structtime\n|      builtins.tuple\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  tmgmtoff\n|      offset from UTC in seconds\n|\n|  tmhour\n|      hours, range [0, 23]\n|\n|  tmisdst\n|      1 if summer time is in effect, 0 if not, and -1 if unknown\n|\n|  tmmday\n|      day of month, range [1, 31]\n|\n|  tmmin\n|      minutes, range [0, 59]\n|\n|  tmmon\n|      month of year, range [1, 12]\n|\n|  tmsec\n|      seconds, range [0, 61])\n|\n|  tmwday\n|      day of week, range [0, 6], Monday is 0\n|\n|  tmyday\n|      day of year, range [1, 366]\n|\n|  tmyear\n|      year, for example, 1993\n|\n|  tmzone\n|      abbreviation of timezone name\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  matchargs = ('tmyear', 'tmmon', 'tmmday', 'tmhour', 'tmmin',...\n|\n|  nfields = 11\n|\n|  nsequencefields = 9\n|\n|  nunnamedfields = 0\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.tuple:\n|\n|  add(self, value, /)\n|      Return self+value.\n|\n|  contains(self, key, /)\n|      Return key in self.\n|\n|  eq(self, value, /)\n|      Return self==value.\n|\n|  ge(self, value, /)\n|      Return self>=value.\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  getitem(self, key, /)\n|      Return self[key].\n|\n|  getnewargs(self, /)\n|\n|  gt(self, value, /)\n|      Return self>value.\n|\n|  hash(self, /)\n|      Return hash(self).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  le(self, value, /)\n|      Return self<=value.\n|\n|  len(self, /)\n|      Return len(self).\n|\n|  lt(self, value, /)\n|      Return self<value.\n|\n|  mul(self, value, /)\n|      Return self*value.\n|\n|  ne(self, value, /)\n|      Return self!=value.\n|\n|  rmul(self, value, /)\n|      Return value*self.\n|\n|  count(self, value, /)\n|      Return number of occurrences of value.\n|\n|  index(self, value, start=0, stop=9223372036854775807, /)\n|      Return first index of value.\n|\n|      Raises ValueError if the value is not present.\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from builtins.tuple:\n|\n|  classgetitem(...) from builtins.type\n|      See PEP 585\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "asctime",
                    "content": "asctime([tuple]) -> string\n\nConvert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\nWhen the time tuple is not present, current time as returned by localtime()\nis used.\n"
                },
                {
                    "name": "clock_getres",
                    "content": "clockgetres(clkid) -> floating point number\n\nReturn the resolution (precision) of the specified clock clkid.\n"
                },
                {
                    "name": "clock_gettime",
                    "content": "clockgettime(clkid) -> float\n\nReturn the time of the specified clock clkid.\n"
                },
                {
                    "name": "clock_gettime_ns",
                    "content": "clockgettimens(clkid) -> int\n\nReturn the time of the specified clock clkid as nanoseconds.\n"
                },
                {
                    "name": "clock_settime",
                    "content": "clocksettime(clkid, time)\n\nSet the time of the specified clock clkid.\n"
                },
                {
                    "name": "clock_settime_ns",
                    "content": "clocksettimens(clkid, time)\n\nSet the time of the specified clock clkid with nanoseconds.\n"
                },
                {
                    "name": "ctime",
                    "content": "ctime(seconds) -> string\n\nConvert a time in seconds since the Epoch to a string in local time.\nThis is equivalent to asctime(localtime(seconds)). When the time tuple is\nnot present, current time as returned by localtime() is used.\n"
                },
                {
                    "name": "get_clock_info",
                    "content": "getclockinfo(name: str) -> dict\n\nGet information of the specified clock.\n"
                },
                {
                    "name": "gmtime",
                    "content": "gmtime([seconds]) -> (tmyear, tmmon, tmmday, tmhour, tmmin,\ntmsec, tmwday, tmyday, tmisdst)\n\nConvert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\nGMT).  When 'seconds' is not passed in, convert the current time instead.\n\nIf the platform supports the tmgmtoff and tmzone, they are available as\nattributes only.\n"
                },
                {
                    "name": "localtime",
                    "content": "localtime([seconds]) -> (tmyear,tmmon,tmmday,tmhour,tmmin,\ntmsec,tmwday,tmyday,tmisdst)\n\nConvert seconds since the Epoch to a time tuple expressing local time.\nWhen 'seconds' is not passed in, convert the current time instead.\n"
                },
                {
                    "name": "mktime",
                    "content": "mktime(tuple) -> floating point number\n\nConvert a time tuple in local time to seconds since the Epoch.\nNote that mktime(gmtime(0)) will not generally return zero for most\ntime zones; instead the returned value will either be equal to that\nof the timezone or altzone attributes on the time module.\n"
                },
                {
                    "name": "monotonic",
                    "content": "monotonic() -> float\n\nMonotonic clock, cannot go backward.\n"
                },
                {
                    "name": "monotonic_ns",
                    "content": "monotonicns() -> int\n\nMonotonic clock, cannot go backward, as nanoseconds.\n"
                },
                {
                    "name": "perf_counter",
                    "content": "perfcounter() -> float\n\nPerformance counter for benchmarking.\n"
                },
                {
                    "name": "perf_counter_ns",
                    "content": "perfcounterns() -> int\n\nPerformance counter for benchmarking as nanoseconds.\n"
                },
                {
                    "name": "process_time",
                    "content": "processtime() -> float\n\nProcess time for profiling: sum of the kernel and user-space CPU time.\n"
                },
                {
                    "name": "process_time_ns",
                    "content": "processtime() -> int\n\nProcess time for profiling as nanoseconds:\nsum of the kernel and user-space CPU time.\n"
                },
                {
                    "name": "pthread_getcpuclockid",
                    "content": "pthreadgetcpuclockid(threadid) -> int\n\nReturn the clkid of a thread's CPU time clock.\n"
                },
                {
                    "name": "sleep",
                    "content": "sleep(seconds)\n\nDelay execution for a given number of seconds.  The argument may be\na floating point number for subsecond precision.\n"
                },
                {
                    "name": "strftime",
                    "content": "strftime(format[, tuple]) -> string\n\nConvert a time tuple to a string according to a format specification.\nSee the library reference manual for formatting codes. When the time tuple\nis not present, current time as returned by localtime() is used.\n\nCommonly used format codes:\n\n%Y  Year with century as a decimal number.\n%m  Month as a decimal number [01,12].\n%d  Day of the month as a decimal number [01,31].\n%H  Hour (24-hour clock) as a decimal number [00,23].\n%M  Minute as a decimal number [00,59].\n%S  Second as a decimal number [00,61].\n%z  Time zone offset from UTC.\n%a  Locale's abbreviated weekday name.\n%A  Locale's full weekday name.\n%b  Locale's abbreviated month name.\n%B  Locale's full month name.\n%c  Locale's appropriate date and time representation.\n%I  Hour (12-hour clock) as a decimal number [01,12].\n%p  Locale's equivalent of either AM or PM.\n\nOther codes may be available on your platform.  See documentation for\nthe C library strftime function.\n"
                },
                {
                    "name": "strptime",
                    "content": "strptime(string, format) -> structtime\n\nParse a string to a time tuple according to a format specification.\nSee the library reference manual for formatting codes (same as\nstrftime()).\n\nCommonly used format codes:\n\n%Y  Year with century as a decimal number.\n%m  Month as a decimal number [01,12].\n%d  Day of the month as a decimal number [01,31].\n%H  Hour (24-hour clock) as a decimal number [00,23].\n%M  Minute as a decimal number [00,59].\n%S  Second as a decimal number [00,61].\n%z  Time zone offset from UTC.\n%a  Locale's abbreviated weekday name.\n%A  Locale's full weekday name.\n%b  Locale's abbreviated month name.\n%B  Locale's full month name.\n%c  Locale's appropriate date and time representation.\n%I  Hour (12-hour clock) as a decimal number [01,12].\n%p  Locale's equivalent of either AM or PM.\n\nOther codes may be available on your platform.  See documentation for\nthe C library strftime function.\n"
                },
                {
                    "name": "thread_time",
                    "content": "threadtime() -> float\n\nThread time for profiling: sum of the kernel and user-space CPU time.\n"
                },
                {
                    "name": "thread_time_ns",
                    "content": "threadtime() -> int\n\nThread time for profiling as nanoseconds:\nsum of the kernel and user-space CPU time.\n"
                },
                {
                    "name": "time",
                    "content": "time() -> floating point number\n\nReturn the current time in seconds since the Epoch.\nFractions of a second may be present if the system clock provides them.\n"
                },
                {
                    "name": "time_ns",
                    "content": "timens() -> int\n\nReturn the current time in nanoseconds since the Epoch.\n"
                },
                {
                    "name": "tzset",
                    "content": "tzset()\n\nInitialize, or reinitialize, the local timezone to the value stored in\nos.environ['TZ']. The TZ environment variable should be specified in\nstandard Unix timezone format as documented in the tzset man page\n(eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently\nfall back to UTC. If the TZ environment variable is not set, the local\ntimezone is set to the systems best guess of wallclock time.\nChanging the TZ environment variable without calling tzset *may* change\nthe local timezone used by methods such as localtime, but this behaviour\nshould not be relied on.\n"
                }
            ]
        },
        "DATA": {
            "content": "CLOCKBOOTTIME = 7\nCLOCKMONOTONIC = 1\nCLOCKMONOTONICRAW = 4\nCLOCKPROCESSCPUTIMEID = 2\nCLOCKREALTIME = 0\nCLOCKTAI = 11\nCLOCKTHREADCPUTIMEID = 3\naltzone = 25200\ndaylight = 1\ntimezone = 28800\ntzname = ('PST', 'PDT')\n",
            "subsections": []
        },
        "FILE": {
            "content": "(built-in)\n\n",
            "subsections": []
        }
    },
    "summary": "time - This module provides various functions to manipulate time values.",
    "flags": [],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Measure how long a command took to run.",
        "examples": [
            {
                "description": "Run the `command` and print the time measurements to `stdout`",
                "command": "time {{command}}"
            },
            {
                "description": "Create a very simple stopwatch (only works in Bash)",
                "command": "time read"
            }
        ]
    }
}