Jump to content

how to check the second date is less than first date


antonyjohn

Recommended Posts

<?php
$date1 = "2007-02-02";
$date2 = "2007-03-03";

echo (strtotime($date1) - strtotime($date2)); 

if((strtotime($date1) - strtotime($date2)) == 0){
echo "Same";
}elseif((strtotime($date1) - strtotime($date2)) < 0){
echo "date1 small";
}else{
echo "OK";
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.