Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convertDateTimeRU() #6

Open
KarelWintersky opened this issue Nov 2, 2024 · 0 comments
Open

convertDateTimeRU() #6

KarelWintersky opened this issue Nov 2, 2024 · 0 comments

Comments

@KarelWintersky
Copy link
Contributor

    /**
     * Конвертирует в русскую дату
     * (не используется)
     *
     * @param $datetime
     * @return string
     */
    public static function convertDateTime($datetime):string
    {
        $year_suffix = 'г. ';
        $ruMonths = [
            1 => 'января', 2 => 'февраля',
            3 => 'марта', 4 => 'апреля', 5 => 'мая',
            6 => 'июня', 7 => 'июля', 8 => 'августа',
            9 => 'сентября', 10 => 'октября', 11 => 'ноября',
            12 => 'декабря'
        ];


        if ($datetime === "0000-00-00 00:00:00" || $datetime === "0000-00-00" || empty($datetime)) {
            return "-";
        }

        if (intval($datetime)) {
            $datetime = date('Y-m-d H:i:s', $datetime);
        }

        list($y, $m, $d, $h, $i, $s) = sscanf($datetime, "%d-%d-%d %d:%d:%d");

        return sprintf("%s %s %s %02d:%02d", $d, $ruMonths[$m], $y ? "{$y} {$year_suffix}" : "", $h, $i);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant