PMA\libraries\Util::localisedDate PHP Method

localisedDate() public static method

Writes localised date
public static localisedDate ( integer $timestamp, string $format = '' ) : string
$timestamp integer the current timestamp
$format string format
return string the formatted date
    public static function localisedDate($timestamp = -1, $format = '')
    {
        $month = array(__('Jan'), __('Feb'), __('Mar'), __('Apr'), _pgettext('Short month name', 'May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec'));
        $day_of_week = array(_pgettext('Short week day name', 'Sun'), __('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat'));
        if ($format == '') {
            /* l10n: See https://secure.php.net/manual/en/function.strftime.php */
            $format = __('%B %d, %Y at %I:%M %p');
        }
        if ($timestamp == -1) {
            $timestamp = time();
        }
        $date = preg_replace('@%[aA]@', $day_of_week[(int) strftime('%w', $timestamp)], $format);
        $date = preg_replace('@%[bB]@', $month[(int) strftime('%m', $timestamp) - 1], $date);
        $ret = strftime($date, $timestamp);
        // Some OSes such as Win8.1 Traditional Chinese version did not produce UTF-8
        // output here. See https://sourceforge.net/p/phpmyadmin/bugs/4207/
        if (mb_detect_encoding($ret, 'UTF-8', true) != 'UTF-8') {
            $ret = date('Y-m-d H:i:s', $timestamp);
        }
        return $ret;
    }

Usage Example

Esempio n. 1
0
 /**
  * This function must be named "Footer" to work with the TCPDF library
  *
  * @return void
  */
 public function Footer()
 {
     // Check if footer for this page already exists
     if (!isset($this->footerset[$this->page])) {
         $this->SetY(-15);
         $this->SetFont(PMA_PDF_FONT, '', 14);
         $this->Cell(0, 6, __('Page number:') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
         $this->Cell(0, 6, Util::localisedDate(), 0, 1, 'R');
         $this->SetY(20);
         // set footerset
         $this->footerset[$this->page] = 1;
     }
 }
All Usage Examples Of PMA\libraries\Util::localisedDate
Util