I'm creating two dates and comparing the number of days between them. My script works great but I feel like I'm converting an object several times before its in a usable format. I'm wondering if there is a less awkward way to do it.
// I'm supplied with a timestamp that I create a reference date
$date1 = date_create_from_format('U', 376358400);
// I'm trying to find the next Saturday after a provided date
$date2= strtotime('next Saturday', strtotime('01 FEB 2017'));
// Step one of calculating the number of days apart
$days = date_diff($date1, new DateTime("@$date2"));
// Step two of calculating the number of days apart
$distance = $days->format('%R%a');