This question already has an answer here:
Hello and thanks for the help. I have a table in mysql with 2 columns (date1),(date2).I want to find the days between these two days and calculate a price of 10 dollars for each day through php
</div>
This question already has an answer here:
Hello and thanks for the help. I have a table in mysql with 2 columns (date1),(date2).I want to find the days between these two days and calculate a price of 10 dollars for each day through php
</div>
here you go:
$dt1 = new DateTime("@{$date1}");
$dt2 = new DateTime("@{$date2}");
$interval = $dt1->diff($dt2);
$price = 10 * $interval->d;
This assumes that you are saving your dates $date1
and $date2
as unix timestamps