Page 1 of 1

if (empty("")) variation

Posted: Fri Oct 28, 2005 8:39 am
by $var
hello,

i am trying to show a date, if it exists.
i have been using, if(empty("")) in the past...

but this is conditional on a date value, and the default is 0000-00-00 00:00:00, so the field isn't exactly empty.
i thought that something like this would work:

Code: Select all

<?  
				$next = convertdate($eventresults["Event_Date"]); 
				if ($next == ("0000-00-00 00:00:00")){
				echo "";
				}
				else{
				echo "$next"; 
				}
				exit;
				?>
but it still passes the 0000-00-00 00:00:00, which reads:
WARNING: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970

THE ATTENTION :)

Posted: Fri Oct 28, 2005 8:57 am
by clyndir
"Windows does not support dates prior to midnight ....." you must look out here ;)

Posted: Fri Oct 28, 2005 9:18 am
by $var
yes, i understand that... in this case, if it is 0000-00-00 i would like to not display it at all.
i tried to change the setting in the database so that the default was empty, but date won't allow that.

Posted: Fri Oct 28, 2005 9:28 am
by clyndir
me strange :)

Posted: Fri Oct 28, 2005 9:29 am
by timvw
simply select those rows where date <> "0000-00-00 00:00:00"
Or in case you have them as NULL where date NOT ISNULL