View Single Post
  #1  
Old 22nd June 2010, 06:14
ajax's Avatar
ajax ajax is offline
Senior Member
 
Join Date: Apr 2009
United Kingdom
Posts: 165
Smile [TBDev] Pre time format.
Hey again,maybe now some can help with pre times formatting?

Now I see it like:
Uploaded 2010-06-20 13:12:22 after pre

But would be great if i can see it like:
Uploaded 13hours 12mins 22sec after pre



What code You need to see?

Function at global.php:
PHP Code:
function ago($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[]="1 year"; else $return[]="$year years";
}
if(
$month){
if(
$month==1$return[]="1 month"; else $return[]="$month months";
}
if(
$day){
if(
$day==1$return[]="1 day"; else $return[]="$day days";
}
if(
$hour){
if(
$hour==1$return[]="1 hour"; else $return[]="$hour hours";
}
if(
$minute&&$minute!=00){
if(
$minute==1){
$return[]="1 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;

}

function 
getpre($name$type)
{
$pre['regexp'] = "|<td>(.*)<td>(.*)<td>(.*)</table>|";
$pre['url'] = "http://doopes.com/?cat=454647&lang=0&num=2&mode=0&from=&to=&exc=&inc=" $name "&opt=0";
$pre['file'] = @file_get_contents($pre['url']);
preg_match($pre['regexp'], $pre['file'], $pre['matches']);
/**
* Types:
* 1 = Time
* 2 = Category
* 3 = Realesename
*/
return $pre['matches'][$type];

__________________
"ALWAYS BE YOURSELF.
UNLESS YOU CAN BE A UNICORN.
THEN ALWAYS BE A UNICORN."
Reply With Quote