Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show month name using PHP_intl?

Tags:

php

datetime

I keep getting number instead of month name. I need to get the month name like July.

$formatter = new \IntlDateFormatter(
    "fa_IR@calendar=persian",
    \IntlDateFormatter::FULL,
    \IntlDateFormatter::FULL,
    'Asia/Tehran',
    \IntlDateFormatter::TRADITIONAL
);
$time = new \DateTime();
$formatter->setPattern('yyyy mm dd');
$formatter->format($time)
like image 427
Amin Jafari Avatar asked Dec 24 '22 13:12

Amin Jafari


1 Answers

You can use MMMM.
All available pattern is on this link

$formatter = new \IntlDateFormatter(
    "fa_IR@calendar=persian",
    \IntlDateFormatter::FULL,
    \IntlDateFormatter::FULL,
    'Asia/Tehran',
    \IntlDateFormatter::TRADITIONAL
);
$time = new \DateTime();
$formatter->setPattern('yyyy MMMM dd');
$formatter->format($time)

This question is same as this

like image 138
Honarkhah Avatar answered Jan 07 '23 18:01

Honarkhah