Python > format dates > 30 Apr 2020 to epoch time

Python can do this in one line: (okay 3 if you count the import and the function header)

Code:
import datetime
def dateFormat(date_string):
    return datetime.datetime.strptime(date_string,"%d %b %Y").strftime("%Y-%m-%d")

This is helpful https://strftime.org


Thanks ...... it works

I am almost finished this book.

_ERADwAAQBAJ.jpg
 
For future reference, if someone thinks python can’t do something simple, they are probably wrong. Try googling “python anti gravity”. That’s how powerful python is.
 
Back
Top