title: how to compare date and time in php/ mysql
body: <p>i need to compare date and time in php/mysql basically i have an application and a server the application needs to connect to the server to check new entries into the database. the server receives the datetime as a string from the application which is done here</p>
  
  <pre><code>SimpleDateFormat dateformat = new SimpleDateFormat("yyyy/mm/dd hh:mm:ss");
  Calendar cal = Calendar.getInstance();
  String time = dateformat.format(cal.getTime()); 
  </code></pre>
  
  <p>the server receives the data here</p>
  
  <pre><code>f (isset($_GET["time"]) || isset($_GET["user_id"])) {
  $time = $_GET['time'];
  $u_id = $_GET['user_id'];
  $timestr=date('y-m-d H:i:s',strtotime($time));
  
  $result = mysql_query("SELECT MAX(created_at)from room");
  $Max_time = mysql_result($result, $row);
  $dbMax_time = date('y-m-d H:i:s',strtotime($Max_time));
  </code></pre>
  
  <p>and the comparison needs to be done here</p>
  
  <pre><code>if ($dbMax_time&gt; $timestr) {
      $NewRooms = mysql_query("SELECT * From room WHERE created_at&gt; CAST($timestr AS TIME)");
  }
  </code></pre>
  
  <p>how do i go about this am confused on how to compare please help me to FIX it.</p>