0
  $1date =$row['Date1'];
     $2date = $row['Date2'];
       $datediff = $1date - $2date;
echo $datediff;

I want to count the days between and put into a table the result(10 dollars for each day passed)

marina
  • 29
  • 3

3 Answers3

1

You could do it in MySQL then work it into a variable. Do the initial call

SELECT TIMESTAMPDIFF('Date1','Date2'); 
Kevin Lynch
  • 24,427
  • 3
  • 36
  • 37
1
// convert to unix timestamp
$1date = strtotime($row['Date1']);
$2date = strtotime($row['Date2']);

// 86400 seconds in a day
// floor to round down, change to ceil to round up
$datediff = floor(($1date - $2date) / 86400);

$cost = $days * 10;
Samutz
  • 2,310
  • 4
  • 24
  • 29
0

Try:

$days = date_diff(date_create($row['Date1']), date_create($row['Date2']))->format('%a');
$cost = $days * 10;
jx12345
  • 1,650
  • 2
  • 22
  • 40