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;
}