Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 0.90 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Compare a DateTime object against another in PHP 5.3
  2. function....
  3.     // I can't get this script to execute when I know the time has passed.
  4.     $now = new DateTime("now", new DateTimeZone('UTC'));
  5.     $row_date = new DateTime($row["due_date"], new DateTimeZone('UTC'));
  6.     if ($row_date->format('Y-m-d H:i:s') <= $now->format('Y-m-d H:i:s')) {
  7.         mysql_query(".....")VALUES ("....")or die(mysql_error());
  8.         mysql_query("DELETE FROM ......")or die(mysql_error());
  9.     }
  10.     else {
  11.         // The time has not come yet.
  12.     }
  13.        
  14. if ($row_date <= new DateTime) { /* Do something */ }
  15.        
  16. $ts=strtotime($date);
  17.        
  18. date_default_timezone_set('UTC');
  19. $row_date = strtotime($row["due_date"]);
  20. if ($row_date <= time()) { // The time has come
  21.     mysql_query(".....") VALUES ("....") or die(mysql_error());
  22.     mysql_query("DELETE FROM ......") or die(mysql_error());
  23. }
  24. else {
  25.     // The time has not come yet.
  26. }