I'm trying to rely on IntlDateFormatter to return the current date in a locale-based format. This means DD/MM/YYYY for it_IT, de_DE, fr_FR... or MM/DD/YYYY for en_US and so on for all the possible locales.
I'm trying to follow the same solution I used to retrieve the current month's name:
$formatter = new IntlDateFormatter("it_IT", IntlDateFormatter::FULL, IntlDateFormatter::FULL);
$formatter->setPattern("MMMM");
return $formatter->format($this);
This code correctly returns "January", "gennaio" etc.
The problem is, I cannot figure out the right pattern to get the date in the current locale format. The ICU User Guide mentions the DateTimePatternGenerator class, and this looks like it! But I cannot find it in PHP.
I would like to avoid a custom, huge switch-case and rely on built-in function instead.
It must be pure PHP.
Any help?