Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Python

Date and Time in Python

Work with dates, times, and formatting using datetime.

Date and Time in Python — a practical guide to Python datetime with clear examples you can reuse in real projects.

Python Tutorial Series (42/95). Prefer one article? Read the complete Python tutorial.

Short description

Use `datetime` for timestamps, formatting (`strftime`), and parsing (`strptime`).

datetime basics

from datetime import datetime, timedelta

now = datetime.now()
print(now.strftime('%Y-%m-%d %H:%M'))
print(now + timedelta(days=7))

Leave a reply

Your email address will not be published. Required fields are marked *