Skip to content

Instantly share code, notes, and snippets.

@Lotuashvili
Last active August 31, 2015 14:05
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 Lotuashvili/43851efa33ca41370536 to your computer and use it in GitHub Desktop.
Save Lotuashvili/43851efa33ca41370536 to your computer and use it in GitHub Desktop.
Georgian date convertor for Laravel 5. Ex.: 25 აპრ, 12 ოქტ 2015
<?php
function localizedDate($datetime, $year = false, $lang = false)
{
$lng = ($lang == 'ge' || $lang == 'en') ? $lang : \Lang::getLocale();
$months = [
'ge' => [1 => 'იან', 2 => 'თებ', 3 => 'მარ', 4 => 'აპრ', 5 => 'მაის', 6 => 'ივნ', 7 => 'ივლ', 8 => 'აგვ', 9 => 'სექტ', 10 => 'ოქტ', 11 => 'ნოე', 12 => 'დეკ'],
'en' => [1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec'],
];
$timestamp = strtotime($datetime);
$date = getdate($timestamp);
$month = $months[$lng][$date['mon']];
$result = $date['mday'] . ' ' . $month;
$result = $year ? $result . ' ' . $date['year'] : $result;
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment