Datetimeparser is a python library capable of parsing the english language into datetime objects.
It was created due to the lack of such library and need for it. We knew that there was dateutil but we wanted a more powerful parsing library.
Datetimeparser can even parse complex grammar and sentence structure.
Below you can find some examples of how datetimeparser can be used.
from datetimeparser import parse
print(parse("next 3 years and 2 months"))
# 2025-04-06 11:43:28
print(parse("begin of advent of code 2022"))
# 2022-12-01 06:00:00
print(parse("in 1 Year 2 months 3 weeks 4 days 5 hours 6 minutes 7 seconds"))
# 2023-05-01 17:59:52
print(parse("10 days and 2 hours after 3 months before christmas 2020"))
# 2020-10-05 02:00:00
Use pip to install the library:
$ pip install python-datetimeparser
If you want to contribute to datetimeparser, please use feature branches. If possible, name them after an already opened issue (e.g. feature/131).
We highly appreciate everyone who wants to help our project!
All Normal-Constants
christmas
holy eve
silvester
eastern
nicholas
halloween
april fools day
thanksgiving
saint patrick's day
- saint patricks day
- st. patrick's day
- saint pt. day
- st patrick's day
- st patricks day
valentines day
summer end
- end of summer
- end of the summer
winter end
- end of winter
- end of the winter
spring end
- end of spring
- end of the spring
fall end
- end of fall
- end of the fall
- autumn end
- end of autumn
- end of the autumn
summer begin
- summer
- begin of summer
- begin of the summer
winter begin
- winter
- begin of winter
- begin of the winter
spring begin
- spring
- begin of spring
- begin of the spring
fall begin
- fall
- begin of fall
- begin of the fall
- autumn begin
- autumn
- begin of autumn
- begin of the autumn
morning
evening
lunchtime
aoc begin
- aoc
- begin of aoc
- begin of the aoc
- advent of code begin
- advent of code
- begin of advent of code
- begin of the advent of code
aoc end
- end of aoc
- end of the aoc
- advent of code end
- end of advent of code
- end of the advent of code
end of year
- the end of year
- the end of the year
- end of the year
begin of year
- the begin of year
- the begin of the year
- begin of the year
infinity
today
tomorrow
yesterday
now
- at the moment
- current time
- current time now
All Day-Constants
morning
afternoon
evening
night
morning night
daylight change
- daylight saving
- daylight saving time
midnight
midday
dawn
dusk
sunrise
sunset
lunch
dinner
breakfast
All Weekday-Constants
monday
tuesday
wednesday
thursday
friday
saturday
sunday
All Month-Constants
january
february
march
april
may
june
july
august
september
october
november
december
All Datetime-Constants
days
weeks
months
years
decades
centuries
millenniums
megaannuums
gigaannuums
seconds
minutes
quarters
hours
All Number-Constants
thirty one
thirty
twenty nine
twenty eight
twenty seven
twenty six
twenty five
twenty four
twenty three
twenty two
twenty one
twenty
nineteen
eighteen
seventeen
sixteen
fifteen
fourteen
thirteen
twelve
eleven
ten
nine
eight
seven
six
five
four
three
two
one
All NumberCount-Constants
thirty first
- 31st
- 31.
- thirthyfirst
- thirty-first
thirtieth
twenty ninth
- 29th
- 29.
- twentyninth
- twenty-ninth
twenty eighth
- 28th
- 28.
- twentyeighth
- twenty-eighth
twenty seventh
- 27th
- 27.
- twentyseventh
- twenty-seventh
twenty sixth
- 26th
- 26.
- twentysixth
- twenty-sixth
twenty fifth
- 25th
- 25.
- twentyfifth
- twenty-fifth
twenty fourth
- 24th
- 24.
- twentyfourth
- twenty-fourth
twenty third
- 23rd
- 23.
- twentythird
- twenty-third
twenty second
- 22nd
- 22.
- twentysecond
- twenty-second
twenty first
- 21st
- 21.
- twentyfirst
- twenty-first
twentieth
nineteenth
eighteenth
seventeenth
sixteenth
fifteenth
fourteenth
thirteenth
twelfth
eleventh
tenth
ninth
eighth
seventh
sixth
fifth
fourth
third
second
first