0

Today is 27 Ramadan 1438 in Asia/Tehran. but PHP Intl says today is 28 Ramadan 1438. Anyone know what the problem is?

$DateTime = new DateTime();
$IntlDateFormatter = new IntlDateFormatter(
                    'en_US@calendar=islamic',
                    IntlDateFormatter::FULL,
                    IntlDateFormatter::FULL,
                    'Asia/Tehran',
                    IntlDateFormatter::TRADITIONAL);

echo $IntlDateFormatter->format($DateTime);
Hossein
  • 3,755
  • 2
  • 29
  • 39
  • i write a helper method for this functionality , can visit : [this link](https://stackoverflow.com/questions/43332341/php-intl-can-convert-a-gregorian-date-to-other-calendar-type/46275845#46275845) you can pass Calendar type to them – Honarkhah Sep 18 '17 at 10:59

2 Answers2

2

try this: (changed calender from islamic to islamic-civil)

$DateTime = new DateTime();
$IntlDateFormatter = new IntlDateFormatter(
                    'en_US@calendar=islamic-civil',
                    IntlDateFormatter::FULL,
                    IntlDateFormatter::FULL,
                    'Asia/Tehran',
                    IntlDateFormatter::TRADITIONAL);

echo $IntlDateFormatter->format($DateTime);
2

use islamic-civil instead of islamic