Re: Date comparison going wrong, wrong, wrong

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

 



Dear Duken,

Many thanks for the solution. It worked!

And thanks to everyone else who pitched in with various solutions.

Regards
Terry

On 12 November 2012 10:06, Duken Marga <dukenmarga@xxxxxxxxx> wrote:

> Try this:
>
> $todaydate = strtotime(date("D, M jS, Y g:i:s a"));
> $showenddate = strtotime(date("D, M jS, Y g:i:s a",
> strtotime($showsRecord['end_date'])));
>
>
> if ($todaydate < $showenddate):
>     echo "The date of the show has not yet arrived";
> else:
>     echo "The show has ended";
> endif;
>
> You must convert both $todaydate and $showendate with strtotime()
> function, then you can compare them.
>
> On Mon, Nov 12, 2012 at 1:30 AM, Terry Ally (Gmail) <terryally@xxxxxxxxx>wrote:
>
>> Hi all,
>>
>> I am having a problem with comparing time. I am using the following:
>>
>> $todaydate = date("D, M jS, Y g:i:s a");
>> $showenddate = date("D, M jS, Y g:i:s a",
>> strtotime($showsRecord['end_date']));
>>
>> if ($todaydate > $showenddate):
>>     echo "The date of the show has not yet arrived";
>> else:
>>     echo "The show has ended";
>> endif;
>>
>> The problem that I am encountering is that PHP is rendering the reverse of
>> the equation. For example:
>>
>> If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
>> the message that I am getting is *the show has ended* which is wrong. A
>>
>> test example is at http://www.lakesidesurrey.co.uk/test.php.
>>
>> You can also me what I am doing wrong?
>>
>> Thanks
>> Terry
>>
>
>
>
> --
> Duken Marga
>
>
>


-- 
*Terry Ally*
Twitter.com/terryally
Facebook.com/terryally
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
To print or not to print this email is the environmentally-searching
question!
Which has the highest ecological cost? A sheet of paper or constantly
switching on your computer and connecting to the Internet to read your
email?

[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