If you want to convert seconds to Jira style 1y 1m 1w 1h 1m 1s
:
class Translator implements TranslatorInterface, TranslatorBagInterface
{
protected const TRANS = [
'year' => 'y',
'month' => 'm',
'week' => 'w',
'day' => 'd',
'hour' => 'h',
'minute' => 'm',
'second' => 's',
];
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null)
{
return $parameters[':count'].self::TRANS[$id];
}
public function getCatalogue(string $locale = null)
{
return new \Symfony\Component\Translation\MessageCatalogue('pl_PL');
}
}
$second = 1;
$minute = 60 * $second;
$hours = 60 * $minute;
$day = 24 * $hours;
$week = 7 * $day;
$month = 4 * $week;
$year = 12 * $month;
$sum = $second + $minute + $hours + $day + $week + $month + $year;
$interval = CarbonInterval::seconds($sum)->cascade();
$interval->setLocalTranslator(new Translator());
echo $interval->forHumans(); // 1y 1m 1w 1h 1m 1s