Re: problem with mktime
| From: | Ross | Date: | Sun, 30 Apr 2006 11:51:30 +0000 |
| Subject: | Re: problem with mktime | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235142@lists.php.net to get a copy of this message | ||
soted it ! Thanks.
R.
""Ross"" <ross@aztechost.com> wrote in message
news:AA.28.18514.C82A4544@pb1.pair.com...
>I am using this to compare todays date with dates retieved from a database.
>The problem is it seem to retrun the same value for the $then variable
>
> and can be seen ot working here....
>
> http://nationalservicesscotland.com/cms/time.php
>
>
> <?
>
> session_start();
> include ('../shared/connect.php');
>
> $query= "SELECT headline, id, expiry, link FROM events";
>
> $result= mysql_query($query);
>
>
> while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){
>
>
> $compare= explode("/", $row['expiry']);
>
>
> $day = isset($compare[0]) ? $compare[0] : null;
> echo "day is $day<br>br><br>";
> $month = isset($compare[1]) ? $compare[1] : null;
> echo "month is $month<br>br><br>";
> $year = isset($compare[2]) ? $compare[2] : null;
> echo "year is $year<br>br><br>";
>
> $then = mktime(0,0,0,$month,$day, $year);
>
> $now = mktime (0,0,0,date("m"),date("d"),date("Y"));
>
>
> $diff = $now - $then;
>
> echo "today is $today<BR>";
> echo "expiry date is $ross<br>";
> echo "now mktime value is is $now<br>";
> echo "then mkvalue is $then<br><br>";
> if ($diff < 0 ) {
> /*$text = stripslashes ($row['headline']);
> $newtext = wordwrap($text, 12, "\n", 1);
> $link=$row['link'];
> echo $newtext."<a href=\"$link\">...read
> more</a>"."<br /><br />";*/
>
> }
> }
> ?>