// convert posted string to date time format
$appointment_time1 = date('Y-m-d H:i:s', strtotime($this->getRequest()->getData('datetime')));
// fetch data from db
$appointments = $this->Appointments->find()->select(['appointment_time']);
foreach ($appointments as $appointment) {
echo $appointment->appointment_time->format('Y-m-d H:i:s') == $appointment_time1 ? 'OK' : 'NOT OK';
}
1条答案
按热度按时间wkyowqbh1#
请始终尝试使用
debug()
函数作为变量,以了解两者之间的区别。在你的例子中,
$appointment_time
不是你所期望的,而是\Cake\ORM\Query
对象,而$appointment_time1
是一个字符串。试试看:
或
还可以尝试: