我可以看到這個問題已經解決好幾次了,我仔細閱讀了所有的主題,但可以找到解決我的問題的方法。PHP foreach總是在空時返回01-01-1970
下面是所返回01-01-1970當空代碼:
$candidateid = '{gprh_fabrik_user_enrollment___id}';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query ->select (array('gprh_fabrik_user_training_124_repeat.date_exa_2')) ->from('gprh_fabrik_user_enrollment') ->leftJoin('gprh_fabrik_user_enrollment_repeat_choix_formation ON gprh_fabrik_user_enrollment.id = gprh_fabrik_user_enrollment_repeat_choix_formation.parent_id') ->leftJoin('gprh_fabrik_user_training_124_repeat ON gprh_fabrik_user_enrollment_repeat_choix_formation.choix_formation = gprh_fabrik_user_training_124_repeat.id') ->leftJoin('gprh_fabrik_user_training ON gprh_fabrik_user_training_124_repeat.parent_id = gprh_fabrik_user_training.id') ->having('gprh_fabrik_user_enrollment.id = ' . $db->quote($candidateid)) ->group('gprh_fabrik_user_enrollment.id, gprh_fabrik_user_training_124_repeat.date_exa_2');
$db->setQuery($query);
$row = $db->loadObjectList();
foreach ($row as $item) { return date('d-m-Y', strtotime($item->date_exa_2)); };
會在這裏得到一些幫助。提前致謝。歡呼聲,馬克
'的strtotime($用品 - > date_exa_2)之前'[被返回false](http://php.net/manual/en/function。 strtotime.php)和'date()'將這個假定爲整數'0'。仔細檢查'$ item-> date_exa_2' – castis