On this page
  1. time.strptime
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

time.strptime

Prev: time.strftime | Up: time | Next: time.struct_time
Rel: time.asctime, time.clock_getres, time.clock_gettime, time.clock_gettime_ns
Ref: docs.python.org — time.strptime
Tags: #public #python3 #stdlib #time


Import

import time
from time import strptime

Signature & Overview

time.strptime(string, format) -> struct_time

Parse a string to a time tuple according to a format specification.

Usage

import time

tm = time.strptime("2026-12-02", "%Y-%m-%d")
assert (tm.tm_year, tm.tm_mon, tm.tm_mday) == (2026, 12, 2)

Gotchas

REPL Inspect

from time import strptime
help(strptime)

Linked from

Related notes