8 March, 2017
In Python, this is an easy exercise in using the
datetime format strings:
from datetime import datetime s = "8 March, 2017" d = datetime.strptime(s, '%d %B, %Y') print(d.strftime('%Y-%m-%d'))
See this table for a full description of all the format qualifiers.
Here I use the
datetime.strptime method to convert your datepicker.js string to a Python datetime object. And I use the
.strftime method to print that object out as a string using the format you desire. At first those format strings are going to be hard to remember, but you can always look them up. And they well organized, in the end.