proposed
doesn't work, but the complete:HTML Code:@setlocale(LC_TIME, 'en');
DOES work. No clue why.Code:$locales = ['en_US', 'en_US.utf8', 'en', 'English_United States.1252'];
@setlocale(LC_TIME, $locales);
Printable View
proposed
doesn't work, but the complete:HTML Code:@setlocale(LC_TIME, 'en');
DOES work. No clue why.Code:$locales = ['en_US', 'en_US.utf8', 'en', 'English_United States.1252'];
@setlocale(LC_TIME, $locales);
My bad. Turns out 'en' alone isn't "valid" either. And that's what I had in my clipboard when I pasted. Doh!
EDITED: now recommending:
Add this to the end of includes/configure.php and YOUR_ADMIN/includes/configure.phpCode:@setlocale(LC_TIME, ['en_US', 'en_US.UTF-8', 'en-US']);
Confirmed on admin and storefront in PHP 8.1. Thanks, @drbyte!
I updated my "fix" with adding UTF-8 fallback, just in case.
(FYI The hyphenated uppercase en_US.UTF-8 works on my dev site, where the en_US.utf8 lowercase without hyphen shows as invalid when used on its own. Might be different on different servers with different locale packs installed at the server level.)
And for local PC servers running Windows, it seems 'en-US' may be what's needed.
Confirmed working on php 8.2. Thank you all very much!
Best,
John
So I was getting the HTTP 500 error when going to my store as a user or an admin. I switched the PHP to 8 and still same issue, I switched back to 8.1 and it works.
I was getting the following error
Quote:
[08-Nov-2023 20:52:03 America/New_York] PHP Fatal error: Uncaught IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR in /homepages/website/store/includes/classes/zcDate.php:90
Stack trace:
#0 /homepages/website/store/includes/classes/zcDate.php(90): IntlDateFormatter->__construct()
#1 /homepages/website/store/includes/classes/zcDate.php(39): zcDate->initializeConversionArrays()
#2 /homepages/website/store/includes/autoload_func.php(47): zcDate->__construct()
#3 /homepages/website/store/Skill-ieE-trusT/includes/application_top.php(42): require('/homepages/36/d...')
#4 /homepages/website/store/Skill-ieE-trusT/home.php(9): require('/homepages/36/d...')
#5 /homepages/website/store/Skill-ieE-trusT/index.php(11): require('/homepages/36/d...')
#6 {main}
thrown in /homepages/website/store/includes/classes/zcDate.php on line 90
[08-Nov-2023 20:52:03 America/New_York] Request URI: /store/Skill-ieE-trusT/, IP address: 136.226.82.111
--> PHP Fatal error: Uncaught IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR in /homepages/website/store/includes/classes/zcDate.php:90
Stack trace:
#0 /homepages/website/store/includes/classes/zcDate.php(90): IntlDateFormatter->__construct()
#1 /homepages/website/store/includes/classes/zcDate.php(39): zcDate->initializeConversionArrays()
#2 /homepages/website/store/includes/autoload_func.php(47): zcDate->__construct()
#3 /homepages/website/store/Skill-ieE-trusT/includes/application_top.php(42): require('/homepages/36/d...')
#4 /homepages/website/store/Skill-ieE-trusT/home.php(9): require('/homepages/36/d...')
#5 /homepages/website/store/Skill-ieE-trusT/index.php(11): require('/homepages/36/d...')
#6 {main}
thrown in /homepages/website/store/includes/classes/zcDate.php on line 90.
spoke too soon. I did add the code to the config files and it fixed it.
Code:@setlocale(LC_TIME, ['en_US', 'en_US.UTF-8', 'en-US']);
Few month ago I submitted on github a re-write of class file zc_date.php based on intl date_format object instead of srftime(). It was not accepted at the time but it might change now. Basically instead of using depracated strftime parameters it uses datefm_create if installed and if not date(). I made it compatible with strftime parameters so old plugins still work.
I use this mod on my live site and some test sites and was not affected when updating to PHP 8.1.25 or 8.2.12!
If you want to try it you can just copy class file zc_date.php (after backing up your original version). If you want to be more efficient and eliminate old strftime parameters copy/merge all other files.
By the way I hope that in new Zencart 2.0 strftime % parameter won't be use any more.
here is the link to github repo: https://github.com/piloujp/zcDate_mod
Noting that the zcDate.php class is PHP version-specific, using strftime for PHP versions < 8.1 and using the IntlDateFormatter class (if that PHP extension is installed) otherwise.