Forum Moderators: coopster
The following function is supposed to return how long ago the entered time was. For example, if i enter march 2, it should say 1 month ago.
Anyways, when i enter the current unix timestamp, it tells me it was 36 years ago.
Here's the function
function timetext($seconds){
$day=date("j",$seconds)-1;
$month=date("n",$seconds)-1;
$year=date("Y",$seconds)-1970;
$hour=date("G",$seconds)-1;
$minute=(int) date("i",$seconds);
$returnvalue=false;
if($year){
if($year==1) $return[]="one year"; else $return[]="$year years";
}
if($month){
if($month==1) $return[]="one month"; else $return[]="$month months";
}
if($day){
if($day==1) $return[]="a day"; else $return[]="$day days";
}
if($hour){
if($hour==1) $return[]="one hour"; else $return[]="$hour hours";
}
if($minute&&$minute!=00){
//if($minute==45){
//$return[]="drie kwartier";
//}else
if($minute==30){
$return[]="half an hour";
//}elseif($minute==15){
//$return[]="een kwartier";
}elseif($minute==1){
$return[]="a minute";
}else{
$return[]="$minute minutes";
}
}
for($i=0;$i<count($return);$i++){
if(!$returnvalue){
$returnvalue=$return[$i];
}elseif($i<count($return)-1){
$returnvalue.= ", ".$return[$i];
}else{
$returnvalue.= " and ".$return[$i];
}
}
return $returnvalue;
} Now, the unix timestamp is 10 digits long, but the example i found for this function is only 7.. What kind of timestamp is only 7 digits long?
Anyways, does anyone know how to use this code? There's zero information online about it.