chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Traits/TimestampableAgoTrait.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

/* For licensing terms, see /license.txt */

namespace Chamilo\CoreBundle\Traits;

use Carbon\Carbon;
use Symfony\Component\Serializer\Annotation\Groups;

trait TimestampableAgoTrait
{
    #[Groups(['api'])]
    public function getCreatedAtAgo(): string
    {
        return Carbon::instance($this->getCreatedAt())->diffForHumans();
    }

    #[Groups(['api'])]
    public function getUpdatedAtAgo(): string
    {
        return Carbon::instance($this->getUpdatedAt())->diffForHumans();
    }
}