
Untitled
By: a guest on
May 16th, 2012 | syntax:
None | size: 0.90 KB | hits: 11 | expires: Never
Compare a DateTime object against another in PHP 5.3
function....
// I can't get this script to execute when I know the time has passed.
$now = new DateTime("now", new DateTimeZone('UTC'));
$row_date = new DateTime($row["due_date"], new DateTimeZone('UTC'));
if ($row_date->format('Y-m-d H:i:s') <= $now->format('Y-m-d H:i:s')) {
mysql_query(".....")VALUES ("....")or die(mysql_error());
mysql_query("DELETE FROM ......")or die(mysql_error());
}
else {
// The time has not come yet.
}
if ($row_date <= new DateTime) { /* Do something */ }
$ts=strtotime($date);
date_default_timezone_set('UTC');
$row_date = strtotime($row["due_date"]);
if ($row_date <= time()) { // The time has come
mysql_query(".....") VALUES ("....") or die(mysql_error());
mysql_query("DELETE FROM ......") or die(mysql_error());
}
else {
// The time has not come yet.
}