Python date and time libraries

Updated Nov 2026

Python date libraries parse, convert, and calculate dates and times beyond what the standard datetime module covers. These libraries read the dates in logs, forms, and data files and convert them between time zones for reports and schedules.

Popularity

python-dateutil has the most installs, while Arrow has the most GitHub stars.

LibraryMonthly downloadsStarsLast releaseLicense
python-dateutil
1.2B
2.6KNov 2026BSD-3-Clause
pytz
508.9M
399Oct 2026MIT
tzlocal
192.0M
221Oct 2026MIT
Arrow
73.7M
9.1KOct 2025Apache-2.0
Pendulum
58.3M
6.7KOct 2026MIT
dateparser
44.1M
2.9KNov 2026BSD-3-Clause
holidays
32.7M
2.0KNov 2026MIT
parsedatetime
25.7M
710May 2020Apache-2.0
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryIANA timezone objectsCalendar month/year offsetsRelative date phrases
python-dateutilBuilt-inBuilt-inUndocumented
pytzBuilt-inUnsupportedUnsupported
tzlocalBuilt-inUnsupportedUnsupported
ArrowBuilt-inBuilt-inBuilt-in
PendulumBuilt-inBuilt-inUndocumented
dateparserBuilt-inBuilt-inBuilt-in
holidaysUnsupportedUnsupportedUndocumented
parsedatetimeVia pluginBuilt-inBuilt-in
Built-inVia pluginNot supportedNot documented

Libraries and code examples

python-dateutil

python-dateutil extends Python's standard datetime module. The package installs as python-dateutil and imports as dateutil. parser.parse reads a date string in almost any format and returns a datetime. Calendar math comes from relativedelta, which adds units such as next month or the last week of a month. For repeating dates, rrule follows a superset of the iCalendar recurrence rules.

Downloads / mo
1.2B
Stars
2.6K
Last release
4.0.0
License
BSD-3-Clause

Strengths

  • Month and year offsets. Add or subtract calendar months and years with relativedelta.
  • Recurring dates. Build schedules by frequency, weekday, and day of the month with rrule.

Limitations

  • Guesses on ambiguous dates. Set dayfirst or yearfirst so numeric dates parse in the expected order.
  • Skips invalid recurrence dates. A monthly rule on a day that some months lack skips those months.

Quickstart

From parser.html
$ pip install python-dateutil
from dateutil.parser import parse
parse("2003-09-25")

python-dateutil examples

From open-source projects on GitHub

pytz brings the Olson time zone database into Python. timezone('US/Eastern') returns a zone object, and its localize method attaches that zone to a naive datetime. After arithmetic that crosses a daylight saving change, normalize corrects the offset. The README marks pytz as deprecated and points newer Python versions to the standard zoneinfo module, the type tzlocal returns.

Downloads / mo
508.9M
Stars
399
Last release
2026.6
License
MIT

Strengths

  • Fixes DST arithmetic. Call normalize() after arithmetic on local times that cross a daylight-saving change.

Limitations

  • Deprecated by its maintainer. On Python 3.9 or later, use the standard zoneinfo module in new code.
  • The tzinfo argument misbehaves. Build local times with localize(), not the datetime tzinfo argument.

Quickstart

From README.rst
$ pip install pytz
from datetime import datetime
from pytz import timezone

eastern = timezone('US/Eastern')
loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0))
print(loc_dt.strftime('%Y-%m-%d %H:%M:%S %Z%z'))

pytz examples

From open-source projects on GitHub

tzlocal finds the machine's local time zone, which neither pytz nor zoneinfo can report on their own. get_localzone returns a tzinfo object even when the system has no zone name configured. A second function, get_localzone_name, returns only the name, such as Europe/Paris, when one is set. On Unix the library reads files such as /etc/localtime and /etc/timezone. Current versions return zoneinfo objects instead of pytz objects.

Downloads / mo
192.0M
Stars
221
Last release
5.4.5
License
MIT

Strengths

  • Works without a zone name. get_localzone() returns a timezone even when the system has no zone name configured.

Limitations

  • Returns zoneinfo, not pytz. Stay on version 4.0 for code that still needs pytz objects.
  • Docker setups often break. Set the TZ environment variable in containers so tzlocal finds the right zone.

Quickstart

From README.rst
$ pip install tzlocal
from tzlocal import get_localzone
tz = get_localzone()

tzlocal examples

From open-source projects on GitHub
def _resolve_timezone():
    tz_name = os.getenv("SCHEDULER_TIMEZONE")
    if tz_name:
        try:
            return ZoneInfo(tz_name)
        except (ZoneInfoNotFoundError, ValueError):
            logging.warning(f"Invalid SCHEDULER_TIMEZONE '{tz_name}', defaulting to machine timezone")
    return get_localzone()

Arrow provides a drop-in replacement for Python's datetime that is timezone-aware and set to UTC by default. arrow.get parses ISO strings and timestamps, shift moves a value by hours, days, or weeks, and to converts it to another time zone. For display, humanize returns phrases such as "an hour ago" in many languages. The README credits moment.js, the JavaScript date library, as its inspiration.

Downloads / mo
73.7M
Stars
9.1K
Last release
1.4.0
License
Apache-2.0

Strengths

  • Chains timezone conversions. Parse a value, shift it by calendar units, and convert its timezone in one chain.
  • Humanizes in many locales. Pass a locale to humanize() to get phrases like "an hour ago" in that language.

Limitations

  • Shifts move nonexistent times. Shifts into a daylight-saving gap move to a real time by default. Pass check_imaginary=False to skip that.

Quickstart

From README.rst
$ pip install -U arrow
import arrow
arrow.get('2013-05-11T21:23:58.970460+07:00')

Arrow examples

From open-source projects on GitHub

Pendulum's DateTime class inherits from Python's datetime, so it works where a datetime is expected. Every instance is timezone-aware and in UTC by default. in_timezone converts a value to another zone, add and subtract move it by calendar units, and diff_for_humans describes the gap from now, such as "two minutes ago". Arithmetic across a daylight saving change returns a time that exists on the clock. Arrow covers the same ground with its own type, while Pendulum stays a subclass of datetime.

Downloads / mo
58.3M
Stars
6.7K
Last release
3.3.0
License
MIT

Strengths

  • Converts timezones in one call. Call in_timezone() to move a date into another timezone.
  • Localized relative times. Pass locale to diff_for_humans() to change the language for one call.

Limitations

  • Strict parsing by default. Pass strict=False to fall back to the dateutil parser for other formats.
  • Some drivers check the type. Database drivers such as PyMySQL and mysqlclient check an object's exact type, so they need an adapter registered for DateTime.

Quickstart

From the Pendulum docs
$ pip install pendulum
import pendulum
pendulum.datetime(2015, 2, 5, tz='Europe/Paris')

Pendulum examples

From open-source projects on GitHub

dateparser turns human-readable date strings into datetime objects through one function, dateparser.parse. Absolute dates, relative phrases such as "two weeks ago", and timestamps all parse, in more than two hundred language locales. The language is detected automatically unless languages sets it. Formats passed in date_formats are tried before the general parser. Compared with parsedatetime, dateparser returns a datetime directly instead of a time tuple.

Downloads / mo
44.1M
Stars
2.9K
Last release
1.5.0
License
BSD-3-Clause

Strengths

  • Parses many languages. Pass languages when they are known, and dateparser skips detection.
  • Parses relative dates. Turns phrases like "In two months" into a datetime.

Limitations

  • Fills in missing date parts. Set STRICT_PARSING to reject dates with missing parts.

Quickstart

From README.rst
$ pip install dateparser
import dateparser
dateparser.parse('1991-05-17')

dateparser examples

From open-source projects on GitHub

holidays generates the public holidays of a country, or of a subdivision such as a state or province, as a dict-like object. holidays.country_holidays("US") returns the calendar. Testing a date, a date string, or a timestamp with in says whether that day is a holiday, while get returns the holiday's name. Calendars cover more than two hundred country codes. For markets, financial_holidays("NYSE") returns stock exchange closing days.

Downloads / mo
32.7M
Stars
2.0K
Last release
0.109
License
MIT

Strengths

  • Stock exchange calendars. Call financial_holidays("NYSE") to get trading holidays for an exchange.
  • Names in other languages. Pass language to get holiday names in the language users read.

Limitations

  • Observed days included by default. Set observed=False to get only the official dates, and test it for the country in question.

Quickstart

From README.md
$ pip install --upgrade holidays
from datetime import date
import holidays
us_holidays = holidays.US()  # this is a dict-like object
date(2015, 1, 1) in us_holidays  # True

holidays examples

From open-source projects on GitHub

parsedatetime parses human-readable date and time text, such as "tomorrow", with a Calendar object. Calendar.parse returns a time tuple and a status code, and the tuple needs one more step to become a datetime. For a timezone-aware result, parseDT takes a pytz zone and returns a datetime directly.

Downloads / mo
25.7M
Stars
710
Last release
2.6
License
Apache-2.0

Strengths

  • Parses everyday phrases. Create a Calendar and call parse() on text such as "tomorrow".

Limitations

  • Returns a time tuple. parse() returns a time tuple and a status, so convert it before using it as a datetime.
  • Timezones come from pytz. Pass a pytz timezone to parseDT() to get a timezone-aware result.

Quickstart

From README.md
$ pip install parsedatetime
import parsedatetime
cal = parsedatetime.Calendar()
cal.parse("tomorrow")

parsedatetime examples

From open-source projects on GitHub

FAQ

Start with the standard datetime and zoneinfo modules, and add python-dateutil, with 1.2B downloads a month, for parsing and month math. Choose Arrow or Pendulum for a friendlier API, or dateparser for dates written in other languages.

It adds a forgiving string parser, relativedelta for month and year offsets, rrule for recurring dates, and extra timezone helpers. It works on standard datetime objects instead of replacing them.

Add relativedelta(months=n) from python-dateutil to the date. When the target month is shorter, the result lands on the last day of that month. A plain timedelta counts days, so it can't add calendar months.

Use datetime.strptime when the exact format is known. Use dateutil.parser.parse for most other formats, and dateparser for relative phrases such as "two weeks ago" or dates in other languages.

Use zoneinfo. The pytz maintainer marks pytz as deprecated and points modern Python projects to the standard zoneinfo module. Keep pytz only for older code that depends on its localize() API.

Use holidays. Build a calendar with holidays.country_holidays("US") and test a date with in. Call holidays.financial_holidays("NYSE") for stock exchange holidays.

For coding agents

Found your date and time library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official