Paste an example date/time string to see the guessed format or paste a format string to see a formatted example.
from datetime import datetime
example = "Sun, 20 Jul 1969 20:17:40"
parsed = datetime.strptime(example, "%a, %d %b %Y %H:%M:%S")
formatted_again = f"{parsed:%a, %d %b %Y %H:%M:%S}"Also see: Python f-string format guesser
For general-purpose formatting (numbers, dates, and strings), check out the format page which can guess f-string format specifications from your desired output.
Don't have date string or a format string? Click an example date string or a format string below. Clicking a format string will copy it to your clipboard.
| Description | Example Date String | Format String |
|---|---|---|
Head to the format codes in the datetime docs and see what % codes you need.
Or use the string formatting table on strftime.org or the formatting playground on strfti.me.
Note that page you're on includes a string formatting playground as well.
If you think you've found a date format that's missing or another bug on this page, please report it to help@pythonmorsels.com.