How can I convert a date format from my plugin so it saves correctly? I have a plugin that includes a datepicker.

I initialize the datepicker like this

javascript

$('.datepicker').datepicker({
    'format': 'mm/dd/yyyy',
    'todayHighlight': true
});


I am saving the date from my plugin like this:

$myDate = craft()-&gt;request-&gt;getPost('myDate');
if ($myDate) {
    DateTime::createFromString($myDate, craft()-&gt;timezone);
}

$fieldsLocation = craft()-&gt;request-&gt;getParam('fieldsLocation', 'fields');
$entry-&gt;setContentFromPost($fieldsLocation);


Because I have designated this field to be required, I get an error back saying that the field cannot be blank. Even though I have chosen a date.

If I change my datepicker to use this format:

$('.datepicker').datepicker({
    'format': 'yyyy/mm/dd',
    'todayHighlight': true
});


Everything works.
I like how "human/U.S" friendly the top example is vs. yyyy-mm-dd. 

Since I am populating the entry with this:

$entry-&gt;setContentFromPost($fieldsLocation);


Is there a way to convert what is passed in to the correct format Craft is looking for?

I've tried something like:

$date = date(str_replace('/', '-', craft()-&gt;request-&gt;getPost('myDate')));

$myDate = date('Y-m-d', strtotime($date));


But that is getting overwritten by this guy still:

entry-&gt;setContentFromPost($fieldsLocation);


Thank you for any suggestions!
After $entry-&gt;setContentFromPost($fieldsLocation); you should be able to add another line to explicitly set your calculated date.

$entry-&gt;setContent(array('fieldName' =&gt; $myDate));


Then just proceed with saving the entry as normal.