<?php
function ramas($epoch)
{
$sec=$epoch%60;
$epoch-=$sec;
$minSeconds=$epoch%3600;
$epoch-=$minSeconds;
$min=($minSeconds/60);
$hourSeconds=$epoch%86400;
$epoch-=$hourSeconds;
$hour=($hourSeconds/3600);
$daySeconds=$epoch%604800;
$epoch-=$daySeconds;
$day=($daySeconds/86400);
$week=($epoch/604800);
$output=[];
if($week>0)
$output[]=($week>19?$week.' de săptămâni':$week.' săptămân'.($week!=1?'i':'ă'));
if($day>0)
$output[]=($day>19?$day.' de zile':$day.' zi'.($day!=1?'le':''));
if($hour>0)
$output[]=($hour>19?$hour.' de ore':$hour.' or'.($hour!=1?'e':'ă'));
if($min>0)
$output[]=($min>19?$min.' de minute':$min.' minut'.($min!=1?'e':''));
if($sec>0||$output=='')
$output[]=($sec>19?$sec.' de secunde':$sec.' secund'.($sec!=1?'e':'ă'));
return($output==''?'0 secunde':preg_replace('/, ([^,]+)$/',' și $1',join(', ',$output)));
}