// 修复 Windows 上俄罗斯语言环境的编码
$locale = setlocale(LC_ALL, 'ru_RU.CP1251', 'rus_RUS.CP1251', 'Russian_Russia.1251');
function strftime_fix($format, $locale, $timestamp = time()){
// 修复 Windows 上的 %e
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
}
// 转换
$date_str = strftime($format, $timestamp);
if (stripos($locale, "1251") !== false) {
return iconv("windows-1251","utf-8", $date_str);
} elseif (stripos($locale, "1252") !== false) {
return iconv("windows-1252","utf-8", $date_str);
} else {
return $date_str;
}
}