freepost codebase git repo

[[ 🗃 ^Avlxv freepost ]] :: [📥 Inbox] [📤 Outbox] [🐤 Followers] [🤝 Collaborators] [🛠 Commits]

Clone

HTTPS: git clone https://vervis.peers.community/repos/Avlxv

SSH: git clone USERNAME@vervis.peers.community:Avlxv

Branches

Tags

master ::

date.php

<?php

class Date
{
    public static function ago ($datetime)
    {
        $estimate_time = time() - $datetime;
        
        if( $estimate_time < 1 )
            return 'right now';
        
        $condition = array(
            12 * 30 * 24 * 60 * 60  =>  'year',
            30 * 24 * 60 * 60       =>  'month',
            24 * 60 * 60            =>  'day',
            60 * 60                 =>  'hour',
            60                      =>  'minute',
            1                       =>  'second');
            
        foreach ($condition as $secs => $str)
        {
            $d = $estimate_time / $secs;
            
            if ($d >= 1)
            {
                $r = round ($d);
                return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago';
            }
        }
    }
}


[See repo JSON]