I believe the problem with the way you where comparing the dates is that
a date is considered a string in PHP.  AFAIK, you can't compare two
strings beyond == and !=.

Many of the ways I've seen in the past to compare dates in PHP is to
convert the dates to UNIX timestamps.  You can then take and compare
those.  This should work as, the UNIX timestamp of the date will be
considered an integer, so you can compare them using all the other
operators.

Check out http://us4.php.net/mktime for more information on converting
dates to an Unix timestamp.

HTH,

Conor 




-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Jer
Sent: Thursday, May 05, 2005 2:01 PM
To: [email protected]
Subject: [php-list] Columns show up depending on date

I've got a column in a MySQL table that I want to show up depending on
the date. If it's before the date in the "release_dt" column, the text
should show up. If it's after, the column should not be visible.

Here is the code:

$current = date("Y-n-j");
if($current < $audio["release_dt"])
{
print '<p><i><font color="#DF0000">This recording will be released on
'.$audio["rel_date"].'.</font></i>';
}

What am I doing wrong?

When it's viewed this way, the text doesn't show up at all. When I
change the comparison operator to <=, it doesn't show up. When I
change it to > or >=, the text shows up no matter what the value of
"release_dt" is.

Any suggestions?

Thanks,

Jer




Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links



 





Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to