""Matthew Cothier"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I really need help here. What I am trying to do is the following.
Which database are you using? What format is it returning the date and
time in (string or integer)? It may be simpler to coerce them to integers
and convert that way with div/mod and mktime().
> if($row[3] == $today){
First recommendation: use mysql_fetch_array() (or the equivalent). It
makes life _so_ much simpler, ie $row["date"], $row["start_time"],
$row["end_time"]
> $today = date("m.d.y");
> $time = date("g:i a");
Second recommendation: do time math in decimal seconds.
define("SECONDS_PER_DAY", 86400);
$now = time();
$today = $now - ( $now % SECONDS_PER_DAY );
$tomorrow = $today + SECONDS_PER_DAY;
// this may be easier if date and time are returned as strings
$start_time = strtotime($row["date"] . " " . $row["start_time"]);
$end_time = strtotime($row["date"] . " " . $row["end_time"]);
if ($start_time >= $tomorrow) { // doesn't start today
$when = $row["date"]." at ".$row["start_time"];
}
else if ($start_time > $now) { // starts today but not yet
$when = "Today at ".$row["start_time"];
}
else if ($end_time >= $now) { // already started, ends later
$when = "Now showing";
}
else { // already ended
$when = "Over";
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]