query($sql); $listings = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $listings = []; // In a real app, log this error // error_log($e->getMessage()); } function time_ago($datetime) { $now = new DateTime; $ago = new DateTime($datetime); $diff = $now->diff($ago); $diff->w = floor($diff->d / 7); $diff->d -= $diff->w * 7; $string = array( 'y' => 'year', 'm' => 'month', 'w' => 'week', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', 's' => 'second', ); foreach ($string as $k => &$v) { if ($diff->$k) { $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); } else { unset($string[$k]); } } $string = array_slice($string, 0, 1); return $string ? implode(', ', $string) . ' ago' : 'just now'; } ?>
There are currently no available food donations. Please check back later.
Quantity: = htmlspecialchars($listing['quantity']) ?>
= htmlspecialchars($listing['description']) ?>
Pickup by: = date('M d, Y h:i A', strtotime($listing['pickup_by'])) ?>