Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date comparison help needed 1

Status
Not open for further replies.

Zych

IS-IT--Management
Apr 3, 2003
313
US
Hello Everybody,

I am trying to do a statement like this:

if($row->expdate < now()) {echo "<br> Date Failed";}

It is failing on the now() function. I have done this in a SQL statement but it will not work here. What am I doing wrong? If there is another way to do this I would be grateful. I can not use the date() function because my ISP has an older version of PHP that does not support this. The field I am comparing it to is of type DATE not DATETIME.

Thanks,

Zych
 
now() is a SQL function not a PHP function. The date() function is supported in PHP 3, 4, and 5. What version of PHP is your ISP running?

Ken
 
You are correct. I was thinking of the MySQL DATE() function which is not supported since my ISP is using MySQL 3.xx and not 4.1. Therefore yes I can use it, my mistake. I guess I am confusing my SQL functions and PHP functions.

So I guess I need to change my question. How would I get a similar funtion to now() in PHP? I would need this to compare to a MySQL DATE feild. (Does PHP consider this just a string when comparing it?)

- Zych
 
Thank you. It worked very well.

- Zych
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top