0

Hello,
I've got a script of facebook date but I want to translate the returning day into my language (Monday=>mmday for instance). Could you guy please.

function fb_date($timestamp){  
    $difference = time() - $timestamp;  
    $periods = array("second", "minute", "hour");  
    $ending=" ago";  
    if($difference<60){  
        $j=0;  
        $periods[$j].=($difference != 1)?"s":"";  
        $difference=($difference==3 || $difference==4)?"a few ":$difference;  
        $text = "$difference $periods[$j] $ending";  
    }elseif($difference<3600){  
        $j=1;  
        $difference=round($difference/60);  
        $periods[$j].=($difference != 1)?"s":"";  
        $difference=($difference==3 || $difference==4)?"a few ":$difference;  
        $text = "$difference $periods[$j] $ending";       
    }elseif($difference<86400){  
        $j=2;  
        $difference=round($difference/3600);  
        $periods[$j].=($difference != 1)?"s":"";  
        $difference=($difference != 1)?$difference:"about an ";  
        $text = "$difference $periods[$j] $ending";       
    }elseif($difference<172800){  
        $difference=round($difference/86400);  
        $periods[$j].=($difference != 1)?"s":"";  
        $text = "Yesterday at ".date("g:ia",$timestamp);                                  
    }else{  
        if($timestamp<strtotime(date("Y-01-01 00:00:00"))){  
            $text = date("l j, Y",$timestamp)." at ".date("g:ia",$timestamp);         
        }else{  
            $text = date("l j",$timestamp)." at ".date("g:ia",$timestamp);            
        }  
    }  
    return $text;  
}
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by diafol
0

If fb not available in your lang. Create an array:

$days = array('Sunday'=>'Sul','Monday'=>'Llun',...);

Get the dayname from the string and do a str_replace(). There are loads of ways you can do this - many date functions. Take your pick.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.