Функция определения времени

function VrTime($time = null)
{
    if ($time == null)
        $time = time();

    $timep = "" . date("j M Y в H:i", $time) . "";
    $time_p[0] = date("j n Y", $time);
    $time_p[1] = date("H:i", $time);


    if ($time_p[0] == date("j n Y"))
        $timep = date("H:i:s", $time);


    if (isset($user))
    {
        if ($time_p[0] == date("j n Y", time()))
            $timep = date("H:i:s", $time);
        if ($time_p[0] == date("j n Y", time() - 60 * 60 * 24))
            $timep = "Вчера в $time_p[1]";
    } else
    {
        if ($time_p[0] == date("j n Y"))
            $timep = date("H:i:s", $time);

        if ($time_p[0] == date("j n Y", time() - 60 * 60 * 24))
            $timep = "Вчера в $time_p[1]";
    }


    $timep = str_replace("Jan", "Янв", $timep);
    $timep = str_replace("Feb", "Фев", $timep);
    $timep = str_replace("Mar", "Мар", $timep);
    $timep = str_replace("May", "Мая", $timep);
    $timep = str_replace("Apr", "Апр", $timep);
    $timep = str_replace("Jun", "Июн", $timep);
    $timep = str_replace("Jul", "Июл", $timep);
    $timep = str_replace("Aug", "Авг", $timep);
    $timep = str_replace("Sep", "Сен", $timep);
    $timep = str_replace("Oct", "Окт", $timep);
    $timep = str_replace("Nov", "Ноя", $timep);
    $timep = str_replace("Dec", "Дек", $timep);
    return $timep;
}