Hi guys. I've been looking for a days_remaining() function to work out the timestamp between now and a future date, and how many days it takes to reach the destination date... (only days)
Currently, we're using bulky code in each part such as:
$datenow = date('Y-m-d');
$start_uts = strtotime($datenow);
$end_uts = strtotime($find['end']);
$total_secs = $end_uts - $start_uts;
$days1 = $total_secs / (60 * 60 * 24);
if($end_uts > $start_uts) {
echo " <li><span>".round($days1)." days</span></li>\n";
} else {
echo " <li><span>ENDED</span></li>\n";
}
How could I make this into a function so I could simply use
days_remaining(strtotime($find['end']));
Thanks 🙂