PHP function of the day: date_diff()

For day 19 of 21 in the “PHP Function of the day” series, I’m going to look at date_diff().

Let’s take a look.

<?php

$shoppingDay=date_create(“2020-05-28”);

$payDay=date_create(“2020-06-01”);

$difference = date_diff($shoppingDay,$payDay);

print_r($difference);

echo “<br /><br />”.$difference->format(“%R%a days”);

?>

 

See the output

 

As you an see, this calculates the difference between two dates (something that could be pretty useful).

Leave a Reply

Your email address will not be published. Required fields are marked *