Text.php
public static function formatDateTime(DateTime $date, $locale = null, string $mask = null, bool $short = false): string
    {
        $locale = $locale ?? 'fr';
        if ($mask === null) {
            $localDates = [
                'fr'    => $short ? __("d/m/y H:i") : __("d/m/Y H:i"),
                'en'    => $short ? __("d/m/y H:i") : __("d/m/Y H:i"),
                'en_US' => $short ? __("m/d/y H:i") : __("m/d/Y H:i")
            ];
            $mask = $localDates[$locale];
        }
        return (string) $date->format($mask);
    }
public static function formatDateTime(DateTime $date, $locale = null, string $mask = null, bool $short = false): string
    {
        $locale = $locale ?? 'fr';
        if ($mask === null) {
            $localDates = [
                'fr'    => $short ? __("d/m/y H:i") : __("d/m/Y H:i"),
                'en'    => $short ? __("d/m/y H:i") : __("d/m/Y H:i"),
                'en_US' => $short ? __("m/d/y H:i") : __("m/d/Y H:i")
            ];
            $mask = $localDates[$locale];
        }
        return (string) $date->format($mask);
    }
public static function formatDateTime ( DateTime $ date , $ locale = null , string $ mask = null , bool $ short = false ) : string { $ locale = $ locale ?? 'fr' ; if ( $ mask === null ) { $ localDates = [ 'fr' => $ short ? __ ( "d/m/y H:i" ) : __ ( "d/m/Y H:i" ) , 'en' => $ short ? __ ( "d/m/y H:i" ) : __ ( "d/m/Y H:i" ) , 'en_US' => $ short ? __ ( "m/d/y H:i" ) : __ ( "m/d/Y H:i" ) ] ; $ mask = $ localDates [ $ locale ] ; } return ( string ) $ date -> format ( $ mask ) ; }
Format a datetime with the specified locale
@param DateTime $date
@param string $locale
@return string
@todo use an external library ?
Format a datetime with the specified locale