我面临一个问题。在我的MySQL
日期时间字段中,某些值存储为0000-00-00
,我需要检查这些值。我在下面解释我的代码。
if (strtotime($data['actualdateofaudit']) == 0) {
$data['actualdateofaudit']='';
}else{
$data['actualdateofaudit'] = date('d-m-Y', strtotime($data['actualdateofaudit']));
}
此处actualdateofaudit
是我的日期时间字段列名称。在我的情况下,我无法检查是否有任何像0000-00-00
这样的值。在这里,我需要检查这些类型值。
答案 0 :(得分:0)
试试这个
if (strtotime($data['actualdateofaudit'])) {
$data['actualdateofaudit'] = date('d-m-Y', strtotime($data['actualdateofaudit']));
}else{
$data['actualdateofaudit']='';
}