php - Function to calculate "time until" instead of "time ago" -
i have function shows how long ago something.
but want convert function shows how many days left go. have following code:
function ago($eventtime) { $totaldelay = time() - strtotime($eventtime); if($totaldelay <= 0) { return 'nu'; } else { if($days=floor($totaldelay/86400)) { $totaldelay = $totaldelay % 86400; return $days.' dagen geleden'; } if($hours=floor($totaldelay/3600)) { $totaldelay = $totaldelay % 3600; return $hours.' uur geleden'; } if($minutes=floor($totaldelay/60)) { $totaldelay = $totaldelay % 60; return $minutes.' minuten geleden '; } if($seconds=floor($totaldelay/1)) { $totaldelay = $totaldelay % 1; return $seconds.' seconden geleden'; } } } you know how feature can create function allows see how many days still go, instead of ago?
this (what call) simple "math & time" issue.
change $totaldelay strtotime($eventtime) - time(); //just reverse them, no big deal.
if math, understand why places ofsrtotime($eventtime) & time() changed.
Comments
Post a Comment