Habari\Utils::locale_date PHP Méthode

locale_date() public static méthode

Return a formatted date/time trying to use strftime() AND date()
public static locale_date ( string $format, integer $timestamp ) : string
$format string The format for the date. If it contains non-escaped percent signs, it uses strftime(), otherwise date()
$timestamp integer The unix timestamp of the time to format
Résultat string The formatted time
    public static function locale_date($format, $timestamp)
    {
        $matches = preg_split('/((?<!\\\\)%[a-z]\\s*)/iu', $format, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
        $output = '';
        foreach ($matches as $match) {
            if ($match[0] == '%') {
                $output .= strftime($match, $timestamp);
            } else {
                $output .= date($match, $timestamp);
            }
        }
        return $output;
    }