Yngvarr

Generation

generate functionWed, 22 Mar 2023

day from two dates

function days_between($date1, $date2) { $tmp = DateTime::createFromFormat('Y-m-d', $date1); $start = $tmp->getTimestamp(); $tmp = DateTime::createFromFormat('Y-m-d', $date2); $end = $tmp->getTimestamp(); return round(($end - $start) / (60 * 60 * 24)); }

Questions about programming?Chat with your personal AI assistant