Pendulum

3.2.0 · active · verified Sat Mar 28

Pendulum is a Python package designed to simplify datetime manipulation, offering a more intuitive API and robust timezone handling than Python's native `datetime` module. It provides drop-in replacements for standard datetime classes, making integration seamless. Currently at version 3.2.0, Pendulum maintains an active release cadence, often aligning with new Python versions or significant feature enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create timezone-aware `DateTime` objects, perform common operations like adding time, calculating human-readable differences, and converting between timezones.

import pendulum

# Get current time in a specific timezone
now_paris = pendulum.now('Europe/Paris')
print(f"Current time in Paris: {now_paris}")

# Create a specific datetime
birthday = pendulum.datetime(1990, 7, 15, tz='America/New_York')
print(f"My birthday: {birthday}")

# Add time
next_week = now_paris.add(weeks=1, days=2)
print(f"Next week and two days: {next_week}")

# Calculate difference in a human-readable format
diff = next_week.diff_for_humans(now_paris)
print(f"Difference: {diff}")

# Convert to another timezone
now_london = now_paris.in_timezone('Europe/London')
print(f"Current time in London: {now_london}")

view raw JSON →