# python-dateutil — card for AI agents

Extensions to Python's datetime module for advanced date and time manipulation.

Category: Utilities · PyPI package `python-dateutil` · latest version 4.0.0 (checked 2026-11-01)
Install: `pip install python-dateutil`
License: BSD-3-Clause (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 73.5 (#254 of all tools, 18 of 408 in its category)
- Used in 100 public projects set up for AI coding agents (1.6%)
- Downloads last week: 286,761,279 (as of 2026-11-24), +20.9% over 4 weeks
- GitHub stars: 2,646 (as of 2026-11-24)
- Last push: 2026-11-18

## Often used with
Requests 69.0%, NumPy 66.0%, Pydantic 65.0%, pandas 55.0%, python-dotenv 53.0%, Uvicorn 52.0%

## Links
- AgentGid page: https://agentgid.com/tools/python-dateutil/
- Homepage: https://github.com/dateutil/dateutil
- Repository: https://github.com/dateutil/dateutil


## python-dateutil: read dates and do calendar math in Python

python-dateutil is a free add-on for Python's own date and time tools. Your app can read dates typed in many formats and add months without landing on a day that does not exist. It can also list repeating dates like "last workday of each month" and show a time in another city's time zone.

### Where to use it
- Read dates people type: A form, an email or an imported spreadsheet gives "March 3rd, 2027 at 4:30pm" or "03/04/2027 9am". Your app turns each into a real date it can sort and store.
- Monthly billing on the 31st: A customer subscribes on January 31; each renewal falls on the last day of shorter months instead of skipping into March.
- Repeating dates for payouts: Payouts, reports or reminders happen on "the last workday of each month" or "every second Tuesday"; your app lists the next dates from one rule.
- One meeting time for every city: A booking page shows a call set for 15:00 in Berlin as the matching local time in New York and Tokyo, with summer time handled.
- Repeat rules from calendar files: A calendar export says "FREQ=WEEKLY;BYDAY=TU;COUNT=3"; your app turns that rule into the actual meeting dates.
- Age or time as a member: A profile page shows "member for 2 years, 3 months" or checks that a user is at least 18 from the birth date.

### How to start
- Install it under its package name python-dateutil; in code you import dateutil.

```
pip install python-dateutil
```

- Read a date from text. Missing parts come from a default date you pass in.

```
>>> from dateutil.parser import parse
>>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True)
(datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at '))
```

- Add months, weeks or a weekday to a date with relativedelta.

```
>>> NOW + relativedelta(months=+1, weeks=+1)
datetime.datetime(2003, 10, 24, 20, 54, 47, 282310)
```


### License
Free to use, also in paid and closed-source products. You may pick the BSD-3-Clause or the Apache-2.0 terms for newer code; keep the copyright notice when you ship it.

### Good to know
- Version 4 needs Python 3.11 or newer. The 3.0 line is the last one for older Python and gets only serious fixes.
- Since version 3.0 the world time zone data comes from your system or the separate tzdata package, so keep that package up to date.
- Versions 3.0 and 4.0 both came out in autumn 2026 after a long pause, and both change some results; read the change log before you upgrade an older app.
- It reads written dates, not phrases like "next Tuesday"; in our run that raised an error. Catch the error and ask the user again.
- Zone names like "America/New_York" are not meant to be shown to people as they are; use friendlier city names in your screens.

Checked 2026-11-10 against: https://dateutil.readthedocs.io/en/stable/, https://dateutil.readthedocs.io/en/stable/parser.html, https://dateutil.readthedocs.io/en/stable/relativedelta.html, https://dateutil.readthedocs.io/en/stable/rrule.html, https://dateutil.readthedocs.io/en/stable/tz.html, https://dateutil.readthedocs.io/en/stable/examples.html, https://github.com/dateutil/dateutil/blob/master/README.rst, https://github.com/dateutil/dateutil/blob/master/NEWS, https://github.com/dateutil/dateutil/blob/master/LICENSE, https://github.com/dateutil/dateutil/blob/master/pyproject.toml, https://pypi.org/pypi/python-dateutil/json

### Mistakes to avoid
- Don't: pip install dateutil → Do: pip install python-dateutil==4.0.0, then import dateutil in code (The package name and the import name differ.)
- Don't: next = previous + relativedelta(months=1) in a loop, starting from January 31 → Do: next = start + relativedelta(months=n) from the original start date (Adding to the previous result drifts: in our run the chain gave Feb 28, then Mar 28 and Apr 28 instead of Mar 31 and Apr 30.)
- Don't: isoparse("20200728121240") or other squeezed digits without separators → Do: Send full ISO strings such as 2020-07-28T12:12:40Z, or use parser.parse for loose input (Since 4.0 isoparse needs each field to have exactly the expected digits; our run raised ValueError: Expected 2 digits.)
- Don't: parse("03/04/2027") for European users → Do: parse("03/04/2027", dayfirst=True), or ask for an unambiguous format such as 2027-04-03 (By default the first number is the month, so our run read it as March 4, not April 3.)
- Don't: Storing parse("March 3 2027 4pm") as is and comparing it with dates that have a time zone → Do: Attach the user's zone (dt.replace(tzinfo=tz.gettz(user_zone))) or pass a default with a zone before you store it (Text without a zone gives a date with no zone, and Python refuses to compare it with zoned dates.)

### Questions
- Why does pip install dateutil not work? The package is called python-dateutil; only the name you import in code is dateutil.
- What happens when I add one month to January 31? You get the last day of February. Adding months never jumps past the end of the shorter month.
- Does a parsed date know its time zone? Only if the text has one. Without a zone you get a date with no time zone attached.
- Can I use it in a paid product? Yes. It is under BSD-3-Clause, and newer code also under Apache-2.0; keep the copyright notice in copies you ship.
- Is the project still maintained? Yes. Version 4.0.0 came out on 2026-11-01, eleven days after 3.0.0.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
