so hello i am trying to use this most used php script linked here Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago... but i cannot get it working, i thought i would fill variable with $datetime with the date i want to differente with i am inputting date with this format "1614084957" but yet i get error
Error: Uncaught Error: Class 'datetime' not found in
i dont know what wrong its included the function is above the desired echo
function time_elapsed_string($datetime, $full = false) {
$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]);
}
}
if (!$full) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' ago' : 'just now';
}
if ($page->id == 1) {
$kat = $pages->get('/kategorie/');
include('chunks/hry.php');
}
in hry.php i jsut have som foreach and ifs i have foreach for each a link to game a i wanted to use this function to determine when this game was created,