How to echo all dates between two dates?
for example:
From the date of 2020/07/29
to the date of 2020/08/02
I want to print the results
2020/07/29
2020/07/30
2020/07/31
2020/08/01
2020/08/02
The following code prints only to 2020/07/31
if(isset($_POST['submit'])){
$from_date= $_POST['from_date'];
$to_date = $_POST['to_date'];
for($from_date = $from_date ; strtotime("+$from_date Day") <= $to_date; $from_date++){
echo $from_date . "<br>";
}
}
Result:
2020/07/29
2020/07/30
2020/07/31
HTML FORM
<form action="" method="post">
<input type="date" name="from_date">
<input type="date" name="to_date" >
<input name="submit" type="submit" value="submit">
</form>
Thanks