I have a strange issue with results returned by
strftime(), that seems to be ignoring
I have a dual-language (English and Polish) application written in Yii 1.x. No matter, what language is currently set in
Yii::app()-language setting, results returned by PHP’s
date() are always in English. For example
DateTime::format('j F Y') should print month name in Polish, when current app’s language is set to
pl (I use short notation, if that matters).
At first, I thought, that setting
Yii::app()-language does not control
DateTime::format (is it?). But, then it turned out, that I’m unable to force PHP to write month name in Polish even after manually setting
After some research, I found out, that
DateTime::format() does not pay attention to locales and I should use
strftime instead. However, either I’m doing something wrong does not work at all in my local, Windows-based environment.
For first test, I took following code:
setlocale(LC_TIME, "pl_PL"); echo '$startDate->getTimestamp() = '.$startDate->getTimestamp(); echo 'strftime("%a %e.%l.%Y", $startDate->getTimestamp()) = '.strftime("%a %e.%l.%Y", $startDate->getTimestamp());
And the results are as following:
So, either I’m missing something or after feeding
strftime with correct timestamp, it prints… nothing.
Then, I used [an example code from
strftime's documentation. And, again, no matter, what language is selected by user, it always prints texts in English. Here is an example:
What am I missing? I have absolutely no idea, why
strftime does not work on my system at all (prints nothing or always English text) and why it is ignoring
Can someone shed some light on this problem? How to fix it or what other method use to finally get dates printed with locale matching