This question already has an answer here:
- How to compare two dates in php 16 answers
I need one help.I have an issue while comparing two date inside if condition.I am explaining my code below.
$erresult = mysqli_fetch_array($qrylast);
$ticket = $erresult['ticket_id'];
if ((date("Y-m-d") == $erresult['date'])) {
$id = sprintf("%03d", $ticket++);
$fields = array("date", "ticket_id ");
$tablename = "db_ticket";
$values = array(date("Y-m-d"), $id);
$id1 = db_insert($tablename, $values, $fields);
if ($id1) {
$ticket_id = 'W1' . date("Ymd") . $id;
}
} else {
$id = '001';
$fields = array("date", "ticket_id ");
$tablename = "db_ticket";
$values = array(date("Y-m-d"), $id);
$id1 = db_insert($tablename, $values, $fields);
if ($id1) {
$ticket_id = 'W1' . date("Ymd") . $id;
}
}
here i need to compare today's date with date save inside database.my saved date inside database datatype is also date but here always else part is executing.In my code i have one condition (date("Y-m-d")==$erresult['date'])
and this condition is never executing even two date are same.Please help me to resolve this issue.
</div>