I want to display the date and more precisely the names of the months according to the locale of the country, but for some reason the class IntlDateFormatt
for the name of the month returns the record M05
, which I understand as the month and its number. And I don't understand why this is happening because I installed the icu-dev
library, and as described in the documentation, this locale is not from the user's system, but from the icu
library:
The locale that will be used in intl functions when none is specified (either by omitting the corresponding argument or by passing NULL). These are ICU locales, not system locales. The built-in ICU locales and their data can be explored at » http://demo.icu-project.org/icu-bin/locexp.
Dockerfile:
FROM php:7.4-cli-alpine
RUN apk update && apk add icu-dev bash autoconf g++ make zlib-dev libzip-dev libpng-dev libwebp-dev freetype-dev libjpeg-turbo-dev libpng-dev supervisor \
&& docker-php-ext-configure \
gd --enable-gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install intl pdo_mysql gd zip
RUN mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini
COPY ./common/php/conf.d /usr/local/etc/php/conf.d
COPY ./development/php-cli/conf.d /usr/local/etc/php/conf.d
RUN apk add unzip
# fix work iconv library with alphine
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
COPY ./common/wait-for-it.sh /usr/local/bin/wait-for-it
RUN chmod 555 /usr/local/bin/wait-for-it
RUN addgroup -g 1000 app && adduser -u 1000 -G app -s /bin/sh -D app
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/bin --filename=composer --quiet \
&& rm -rf /root/.composer/cache
WORKDIR /app
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisor.conf"]
USER app
My test script, ua_UK
is a correct locale:
$formatter = new \IntlDateFormatter(
'uk_UA',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL
);
$formatter->setPattern('MMMM');
echo $formatter->format(new \DateTime()); //M05
What is the reason for this behavior?