A
A
Anton2018-08-31 08:45:17
Python
Anton, 2018-08-31 08:45:17

How to convert string like '31 Jul 2018' to date?

Can you please tell me if it is possible to convert the string '31 Jul 2018' into a date? Is there a standard function for this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-08-31
@Trif

In my opinion, it is easier and more logical to use the same datetime, most likely it has already been imported, and there is no need to bloat the project with additional libraries:

from datetime import datetime
d = datetime.strptime( "31 Jul 2018", "%d %b %Y" )

V
Vladislav Kadun, 2018-08-31
@ZXZs

If you like bicycles made of crutches, then you can use regular expressions :)
I have nothing to do, I can write the solution code. Maybe even faster libraries will work :P

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question