if (empty("")) variation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

if (empty("")) variation

Post 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
clyndir
Forum Newbie
Posts: 7
Joined: Fri Oct 28, 2005 8:05 am

THE ATTENTION :)

Post by clyndir »

"Windows does not support dates prior to midnight ....." you must look out here ;)
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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.
clyndir
Forum Newbie
Posts: 7
Joined: Fri Oct 28, 2005 8:05 am

Post by clyndir »

me strange :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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
Post Reply