Created
November 18, 2019 19:58
-
-
Save AkioSarkiz/2d6e901505931a872e9f48078b2ef86d to your computer and use it in GitHub Desktop.
Convert date to rus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# -------------------------- | |
# @author Akio Sarkiz | |
# @date 18.11.2019 | |
# -------------------------- | |
declare(strict_types = 1); | |
final class Convert | |
{ | |
public static function convertDateToRusFormat(\DateTime $time): String | |
{ | |
return | |
$time->format('d ') . | |
['Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря'][$time->format('m')-1] . | |
(($time->format('Y') == (new \DateTime())->format('Y')) ? '' : $time->format(' Y года')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment