The Python Oracle

Pythonic way to combine datetime.date and datetime.time objects

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: City Beneath the Waves Looping

--

Chapters
00:00 Question
00:31 Accepted answer (Score 455)
00:49 Thank you

--

Full question
https://stackoverflow.com/questions/8474...

Accepted answer links:
[python docs]: http://docs.python.org/release/2.6/libra...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#datetime #python

#avk47



ACCEPTED ANSWER

Score 479


It's in the python docs.

import datetime
datetime.datetime.combine(datetime.date(2011, 1, 1), 
                          datetime.time(10, 23))

returns

datetime.datetime(2011, 1, 1, 10, 23)