How do I format a date value for a 3-column date drop-down widget? I would like to pass a date in the format 2013-04-23 00:00:00 as a #default_value into a form builder function:

$form['date'] = array(
    '#title' =&gt; t('Date'),
    '#type' =&gt; 'date',
    '#default_value' =&gt; $my-array['date'],
);


...but the form renders dates in a three column drop-down widget (which I want to keep). How do I reformat my date and/or form builder function so that my three drop-downs display 23 Apr 2013? At present, they display 02 Feb 1900.

Thanks

Solution

See @tostinni's answer for half of the soluion. This is the second half:

$timestamp = strtotime($my-array['date']);
$day = date('d', $timestamp);
$month = date('n', $timestamp);
$year =  date('Y', $timestamp);
The Form API documentation will help you figure this out, you'll have to pass an array with the year, month and day keys like this:

$form['date'] = array(
    '#title' =&gt; t('Date'),
    '#type' =&gt; 'date',
    '#default_value' =&gt; array('year' =&gt; 2013, 'month' =&gt; 4, 'day' =&gt; 23),
);