Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class "IntlDateFormatter" not found -php 8.2 #24

Open
gtbu opened this issue Nov 6, 2023 · 4 comments
Open

Class "IntlDateFormatter" not found -php 8.2 #24

gtbu opened this issue Nov 6, 2023 · 4 comments

Comments

@gtbu
Copy link
Owner

gtbu commented Nov 6, 2023

Under php 8.2 , a click at the revision-history-button gives

Class "IntlDateFormatter" not found - in ....\thirdparty\time\strftime.php on line: 61 (54) -

and add behind the first line

namespace PHP81_BC;

use DateTime;
use DateTimeZone;
use DateTimeInterface;
use Exception;
use IntlDateFormatter;
use IntlGregorianCalendar;
use InvalidArgumentException;

@TheWitness
Copy link

You should ensure that php-intl is installed. Run php -m and look for Intl

@gtbu
Copy link
Owner Author

gtbu commented Mar 18, 2024

Yes - but intl is nowadays a standard - except under Xampp, where You sholud activate intl and zip in the php.ini

@TheWitness
Copy link

The INTL library can not handle common sprintf like:

strftime("The rain in Spain falls on the %M'th day of %Y\n");

Why I say they messed up.

@gtbu
Copy link
Owner Author

gtbu commented Mar 24, 2024

  • The new strftime rewrites the old function strftime with intl-functions so that the old syntax functions with php8.x

In PHP 8.1 and later versions, you can use the DateTimeImmutable class to achieve similar functionality as the strftime() function.

*The strftime function was used to format local time or date according to locale settings, but it has been replaced by the DateTimeInterface::format method. The DateTimeInterface::format method is more powerful and flexible than strftime, and it allows for more customization and control over the formatting of dates and times.

*An alternative is the IntlDateFormatter::format method instead.

  • or
    $date = new DateTimeImmutable('now');
    echo $date->format('%B %d, %Y'); // Outputs "March 24, 2024"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants