how to compare date and time in php/ mysql -
i need compare date , time in php/mysql have application , server application needs connect server check new entries database. server receives datetime string application done here
simpledateformat dateformat = new simpledateformat("yyyy/mm/dd hh:mm:ss"); calendar cal = calendar.getinstance(); string time = dateformat.format(cal.gettime());
the server receives data here
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));
and comparison needs done here
if ($dbmax_time> $timestr) { $newrooms = mysql_query("select * room created_at> cast($timestr time)"); }
how go confused on how compare please me fix it.
just comparing 2 timestamps suffice:
$t1 = strtotime($time); $t2 = strtotime($max_time); if($t1 > $t2) { .. }
Comments
Post a Comment