Basically what I want to do is to send an email to follow up on order placed in 3 hours later.
What I try to do is to get the current date (up to hours level), then compare with the orderdate+ 3 hours, to see whether it match.
Example orderdate: 2010-06-12 18, after add 3 hours should become 2010-06-12 21
However, after add hour, the final result sometimes become bigger, sometimes become smaller... something wrong.
$now= date('Y-m-d H');
echo $now . "<br>";
...
...
while ($data = mysql_fetch_array ($result))
{
$orderid = $data['orderid'];
$orddate = $data['orddate'];
$corddate= date('Y-m-d H:i:s', $orddate);
$year = substr ($corddate, 0, 4);
$month = substr ($corddate, 5, 2);
$day = substr ($corddate, 8, 2);
$hour = substr ($corddate, 11, 2);
$actualorderdate= $year . "-" . $month . "-" . $day . " " . $hour;
$new_time = mktime ($hour+3, 0, 0, $month, $day, $year);
$year = date ('Y', $new_time);
$month = date ('m', $new_time);
$day= date ('d', $new_time);
$hour= date ('h', $new_time);
$xhourslater= $year . "-" . $month . "-" . $day . " " . $hour;
echo "actualorderdate: ". $actualorderdate. " xhourslater: " . $xhourslater. "<br>";
if($now==$xhourslater)
{
echo "now is 3 hours later" . "<br>";
//send email follow up, then update status as sent, in order not to resend anytime in the 3rd hour.
}
}