Please use this code: $first_date = new DateTime("2022-01-01"); $second_date = new DateTime("2023-02-02"); $difference = $first_date->diff($second_date); echo "<difference> = " . $difference->y . " years, " . $difference->m." months, ".$difference->d." days " . "<difference in dRead more
Please use this code:
1
2
3
4
5
$first_date=newDateTime("2022-01-01");
$second_date=newDateTime("2023-02-02");
$difference=$first_date->diff($second_date);
echo"<difference> = ".$difference->y." years, ".$difference->m." months, ".$difference->d." days "."<difference in days> =".$difference->days." days ";
How to calculate the difference between two dates using PHP language?
Please use this code: $first_date = new DateTime("2022-01-01"); $second_date = new DateTime("2023-02-02"); $difference = $first_date->diff($second_date); echo "<difference> = " . $difference->y . " years, " . $difference->m." months, ".$difference->d." days " . "<difference in dRead more
Please use this code:
It works as you expect
See less