2018-09-21 22:11:49 +02:00
|
|
|
<?php namespace Todaymade\Daux;
|
|
|
|
|
|
|
|
use IntlDateFormatter;
|
|
|
|
|
|
|
|
class FormatDate
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
public static function format($config, $date) {
|
|
|
|
$locale = $config->getLanguage();
|
2018-09-21 22:11:49 +02:00
|
|
|
$datetype = IntlDateFormatter::LONG;
|
|
|
|
$timetype = IntlDateFormatter::SHORT;
|
|
|
|
$timezone = null;
|
|
|
|
|
|
|
|
if (!extension_loaded("intl")) {
|
|
|
|
$locale = 'en';
|
|
|
|
$timezone = 'GMT';
|
|
|
|
}
|
|
|
|
|
|
|
|
$formatter = new IntlDateFormatter($locale, $datetype, $timetype, $timezone);
|
|
|
|
|
|
|
|
return $formatter->format($date);
|
|
|
|
}
|
|
|
|
}
|