//Fix encoding for russian locale on windows
$locale = setlocale(LC_ALL, 'ru_RU.CP1251', 'rus_RUS.CP1251', 'Russian_Russia.1251');
function strftime_fix($format, $locale, $timestamp = time()){
// Fix %e for windows
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
}
// convert
$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;
}
}