// Fields in question
// txtDay2Date --> Date field from calendar control --> this field
// txtDay2Start --> time field, will format it to come in as hh:mm
// selDay2Start --> AM/PM

$date = $value;
$time = JRequest::getVar('ff_nm_txtDay2Start',array(''));
$time = $time[0];
$z = JRequest::getVar('ff_nm_selDay2Start',array(''));
$z = $z[0];

// Need single value to be YYYY-MM-DD HH:MM:SS

// Date formatted as mm/dd/yyyy
list($m, $d, $y) = preg_split('/\//', $date);
// Date reformatted as yyyy-mm-dd
$date = sprintf('%4d-%02d-%02d', $y, $m, $d);

// Time formatted as hh:mm
list($h, $m) = preg_split('/:/', $time);
if($z == 'PM' && $h != '12') { $h = $h + 12; }

// Time reformatted as hh:mm:00
$time = sprintf('%02d:%02d:00', $h, $m);

// Tie the two together into a SQL timestamp
$value = $date .' ' .$time;