time üzerinden kalan zamanı gösteriyor

PHOTO EMBED

Thu Mar 02 2023 13:20:22 GMT+0000 (Coordinated Universal Time)

Saved by @raca12 #php

function time_elapsed_string($ptime)
{
    $etime = $ptime - time();

    if ($etime < 1)
    {
        return '0 seconds';
    }

    $a = array( 365 * 24 * 60 * 60  =>  'year',
                 30 * 24 * 60 * 60  =>  'month',
                      24 * 60 * 60  =>  'day',
                           60 * 60  =>  'hour',
                                60  =>  '',
                                 1  =>  ''
                );
    $a_plural = array( 'year'   => 'years',
                       'month'  => 'months',
                       'day'    => 'days',
                       'hour'   => 'hours',
                       'minute' => '',
                       'second' => ''
                );

    foreach ($a as $secs => $str)
    {
        $d = $etime / $secs;
        if ($d >= 1)
        {
            $r = round($d);
            return $r . '' . ($r > 1 ? $a_plural[$str] : $str);
        }
    }
}
content_copyCOPY