Re: Display cell if dates are between 2 dates - help
| From: | BigDog | Date: | Sat, 16 Nov 2002 16:10:40 +0000 |
| Subject: | Re: Display cell if dates are between 2 dates - help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-124752@lists.php.net to get a copy of this message | ||
This is how i deal with dates...
$date = date in the database.
$today = strtotime( gmdate( "Y-m-d" ) );
$spd = 60 * 60 * 24; // seconds per day
$fdate = strtotime( substr( $date, 0, 10 ) );
$future = ( $fdate - $today ) / $spd;
do the comparision with $future and it should work for yeah...
Basically, I convert it all to seconds and do the math...
On Sat, 2002-11-16 at 20:10, Ray Healy (Data Net Services) wrote:
> Dear all
>
> I'm trying to create a search function that can check the current day in a calendar
> against a mysql database where there is a startdate and enddate and if the date is there then colour
> code the cell in the calendar.
>
> I have tried to use the following command
>
> $eventQuery = "SELECT title FROM prestigecal WHERE '$sql_currentday' BETWEEN
> startdate AND enddate;";
>
> The database has an ID - title - startdate - enddate
>
> This seems to work BUT if the date in the database is a single number i.e. 0 to 9 it cannot
> dispaly it and also if the startdate or endate is a 10, 20 or 30 it also thinks that it is a 1, 2or
> 3
>
> Just in case it helps the full codede for this section is as follows :
>
> /snip
> $sql_currentday = "$year-$month-$zz";
> $eventQuery = "SELECT title FROM prestigecal WHERE '$sql_currentday' BETWEEN
> startdate AND enddate;";
> $eventExec = mysql_query($eventQuery);
> while($row = mysql_fetch_array($eventExec)) {
> if (strlen($row["title"]) > 0) {
> echo "<td bgcolor=\"red\" valign=\"middle\"
> align=\"center\"><font size=\"1px\"
> face=\"Verdana\">$zz</font></td>\n";
> $result_found = 1;
> /snip
>
>
> Thanks for any advice.
>
> Ray
--
.: B i g D o g :.