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
Post a Comment