0

I am beginner using bootstrap PDO and php. javascript How can I compare 2 date like image below.

enter image description here

user3783243
  • 5,368
  • 5
  • 22
  • 41
  • 1
    You're going to have to narrow down where you want to compare it. Bootstrap is mostly for CSS, so ignore that. If you want to alert the user immediately, then you'll need javascript. If you want to compare it after the form is submitted, then you'll need PHP. There are already a lot of answers on SO on how to compare dates in both languages. – aynber Feb 23 '22 at 15:01
  • 2
    It would also be nice to know how you want to compare the dates. If you don't understand what I mean you could, instead, say **why** you want to compare them. – KIKO Software Feb 23 '22 at 15:14

1 Answers1

0

It depens on when/where u want to compare them. While filling out the form will require JS/Jquery. After submitting requires PHP.

In PHP it should work like this:

$date1 = "2022-02-02";
$date2 = "2021-01-01";
$dateTime1 = strtotime($date1);
$dateTime2 = strtotime($date2);

if ($dateTime1 > $dateTime2){
   echo "$date1 is latest than $date2";
}else{
   echo "$date1 is older than $date2";
}

PHP manual strtotime().

For JQuery use this thread.