Convert string date into date format in python? -


how convert below string date date format in python.

input: date='15-march-2015'  expected output: 2015-03-15 

i tried use datetime.strftime , datetime.strptime. not accepting format.

you can use datetime.strptime proper format :

>>> datetime.strptime('15-march-2015','%d-%b-%y') datetime.datetime(2015, 3, 15, 0, 0) 

read more datetime.strptime , date formatting: https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -