Reputation: 77
I am using drupal 7 date_popup field type for my form:
$form['departure_date_1']= array(
'#type' => 'date_popup',
'#date_format' => 'Y-m-d',
'#defalut_value'=>date('Y-m-d',strtotime($date_part1)),
);
$date_part1 is string:"2014-03-12", i use strtotime to convert it to date. i also tried:
$form['departure_date_1']= array(
'#type' => 'date_popup',
'#date_format' => 'Y-m-d',
'#defalut_value'=>date('Y-m-d'),
);
Or:
$form['departure_date_1']= array(
'#type' => 'date_popup',
'#date_format' => 'Y-m-d',
'#defalut_value'=>'2014-03-12',
);
none of them works, the filed is blank all the time, i searched the whole day, but still can not find the problem.
Upvotes: 0
Views: 1813
Reputation: 2222
Better to go with the core function
format_date($date, 'custom', $format)
source: https://stackoverflow.com/a/16485564/195812
Upvotes: 1