strftime workaround for php on windows

The %e and %k modifiers are not supported in the Windows implementation of the
strftime function.

The workaround is from the strftime documention (Example #3).
This commit is contained in:
Mathias Kresin 2014-12-02 18:46:47 +01:00
parent 923ef7c0ef
commit 4641b5c66b

View File

@ -72,6 +72,11 @@ namespace Translator {
function datetime($format, $timestamp) function datetime($format, $timestamp)
{ {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
$format = preg_replace('#(?<!%)((?:%%)*)%k#', '\1%#H', $format);
}
return strftime($format, (int) $timestamp); return strftime($format, (int) $timestamp);
} }