Re: compare dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Nov 30, 2011, at 5:04 PM, Matijn Woudt wrote:

> On Wed, Nov 30, 2011 at 11:00 PM, Marc Fromm <Marc.Fromm@xxxxxxx> wrote:
>> I'm puzzled why the if statement executes as true when the first date (job_closedate) is not less than the second date (now).
>> The if statement claims that "12/02/2011" is less than "11/30/2011".
>> 
>>                if (date("m/d/Y",strtotime($jobs_closedate)) <= date("m/d/Y",strtotime("now"))){
> 
> You're comparing strings here, try to compare the unix timestamp:
> 
> if (strtotime($jobs_closedate) <= strtotime("now")){
> 
> That'll probably do what you want..
> 
> Matijn
> 

Another way to do it would be:
if(strtotime($jobs_closedate)<=time()) {
}

or

if(date("Y-m-d",strtotime($job_closedate))<=date("Y-m-d",time()) {
}

Take care,
Floyd



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux