Skip to content

Instantly share code, notes, and snippets.

@AkioSarkiz
Created November 18, 2019 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkioSarkiz/2d6e901505931a872e9f48078b2ef86d to your computer and use it in GitHub Desktop.
Save AkioSarkiz/2d6e901505931a872e9f48078b2ef86d to your computer and use it in GitHub Desktop.
Convert date to rus
<?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