检查日期是否为空 [英] Check if date is empty

查看:131
本文介绍了检查日期是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

中循环中,如果该日期存在,我该如何才能显示日期



例如:如果日期 0000-00-00 ,则不显示任何内容。



我目前阅读日期如下,但当 0000-00-00 时,我得到 01-01-1970 : p>

  date('dm -Y',strtotime($ row ['date']))
  while($ row = mysql_fetch_array($ result)){

if(strtotime($ row ['date'])!='0000-00-00'){
mydate = date('dm -Y',strtotime($ row ['date'])) ;
} else {
mydate ='';
}
}


In a while loop how can I have a date displayed only if that date exists?

E.g.: If date is 0000-00-00, display nothing.

I am currently reading the date as follows, but I am getting 01-01-1970 when 0000-00-00:

date('d-m-Y', strtotime($row['date']))

解决方案

You should check first what is there in date field whether it contains date or its NULL. According to result you can read date .

while($row = mysql_fetch_array($result)){ 

if(strtotime($row['date'])!='0000-00-00'){
mydate = date('d-m-Y', strtotime($row['date']));
}else{
mydate ='';
}
}

这篇关于检查日期是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆