Python date parser that handles 200+ locales and relative dates
GitHub RepoImpressions727
View on GitHub
@githubprojectsPost Author

Parsing Dates in 200+ Locales? This Python Library Does the Heavy Lifting

If you've ever tried to parse dates from a user input field or scraped text, you know the pain. One person writes "March 3rd, 2024", another writes "03/03/24", and someone else writes "3 mars 2024" (if they're in France). Python's built-in datetime and dateutil handle the common formats, but add relative dates like "2 days ago" or "next Thursday" and things get messy fast.

There's a library that handles exactly this — and it's been around quietly doing excellent work. Let me introduce you to dateparser.

What It Does

dateparser is a Python library for parsing dates from strings. The headline feature: it supports over 200 locales and also handles relative dates. You feed it a string, it returns a Python datetime object. That's it.

Under the hood, it uses a combination of language detection, locale-specific tokenization, and fuzzy matching to figure out what "last martes" or "il y a 3 jours" means and convert it to a concrete date.

Why It's Cool

1. 200+ locales out of the box
This is the killer feature. You don't need to install separate locale packages or write custom parsers for each language. Just pass the string and optionally set the language hint. Chinese, Arabic, Hindi, Swedish — it's all covered.

2. Relative dates with zero effort
Strings like "2 weeks ago", "tomorrow", "next Friday", "yesterday at 3pm" — they all parse correctly without any configuration. This is incredibly useful for scraping, chatbots, or processing user input in apps.

3. Handles ambiguous dates gracefully
It can deal with "03/04/2024" and correctly interpret it based on the locale (US: March 4, EU: April 3). You can also set a DATE_ORDER preference when ambiguity matters.

4. Built for speed and reliability
The library has been around for years (since ~2015) with relatively stable APIs. It's used by scrapinghub (the company behind Scrapy) in production for millions of date strings. It's mature and well-tested.

5. Simple API
You just call parse() with a string. Optionally pass languages, locales, or settings for fine control.

import dateparser

dateparser.parse("2 days ago")
# returns datetime object for 2 days ago

dateparser.parse("3 mars 2024", languages=['fr'])
# datetime(2024, 3, 3)

How to Try It

Install it in under a minute.

pip install dateparser

Then test it in a Python shell:

import dateparser

# Try some examples
print(dateparser.parse('last Tuesday'))
print(dateparser.parse('2 jours avant', languages=['fr']))
print(dateparser.parse('2024年3月5日', languages=['zh']))

For a quick online demo, the project's README links to a live example.

If you're dealing with dates from multiple languages or user-submitted text, just install it and start using parse() — that's 90% of what you'll need.

Final Thoughts

dateparser is one of those libraries that feels like magic until you realize how much work went into the language data and parsing logic. It's not flashy, it's not new, but it's the kind of tool that saves you hours of frustrated regex writing.

If you're building anything that touches dates — a data ingestion pipeline, a dashboard that accepts natural language, or a scrapy spider — give it a try. You'll probably end up keeping it in your requirements.txt forever.


Found this useful? Follow @githubprojects for more developer tools and hidden gems on GitHub.

Back to Projects
Last updated: June 15, 2026 at 05:07 AM