https://www.opencart.com/index.php?rout ... n_id=27267
Make sure you refresh the modification cache after installing.
Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD lover, user and geek.
Affordable Service £££ - Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
FREE Guidance and Advice at https://www.ecommerce-help.co.uk
Thanks but this says it changes the date to the US date format d/m/Y, whereas the US date format is m/d/Y. I would like m/d/Yjohnp wrote: ↑Wed Jan 08, 2025 3:17 amTry this. It works for me:
https://www.opencart.com/index.php?rout ... n_id=27267
Make sure you refresh the modification cache after installing.
If you have the Modification Manager extension you can install the Ocmod then edit it online to get the format you need.mazman wrote: ↑Wed Jan 08, 2025 4:16 amThanks but this says it changes the date to the US date format d/m/Y, whereas the US date format is m/d/Y. I would like m/d/Yjohnp wrote: ↑Wed Jan 08, 2025 3:17 amTry this. It works for me:
https://www.opencart.com/index.php?rout ... n_id=27267
Make sure you refresh the modification cache after installing.
https://www.opencart.com/index.php?rout ... n_id=22318
Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD lover, user and geek.
Affordable Service £££ - Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
FREE Guidance and Advice at https://www.ecommerce-help.co.uk
That sounds exactly like what the OP tried manually.Change short date to US format d/m/Y. It accomplish this by changing the date_format_short variable in the language file of english directory.
Because often these dates are hardocded inside the corresponding controller.
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
The main language files are loaded at startup in catalog/controller/startup/startup.php.
There it creates a new language object which in turn loads the default en-gb.php file (containing array definitions) and the current language file if present and it merges these array key-values. I assume so that if a language definition is missing, the en-gb is always there as a fallback.
you could add something like:
Code: Select all
$this->log->write('date short definition: '. $this->language->get('date_format_short'));
Code: Select all
$this->registry->set('language', $language);
If it is, that value is overwritten somewhere or simply not used.
I tried the above but see no reference to the short date in the logs. I looked in the https logs, the storage/logs, and also the logs from the dashboard>system>maintnance>error logs. Are there others I should be looking at? I liked this approach to the issue.nonnedelectari wrote: ↑Thu Jan 09, 2025 6:10 pmThe main language files are loaded at startup in catalog/controller/startup/startup.php.
There it creates a new language object which in turn loads the default en-gb.php file (containing array definitions) and the current language file if present and it merges these array key-values. I assume so that if a language definition is missing, the en-gb is always there as a fallback.
you could add something like:after:Code: Select all
$this->log->write('date short definition: '. $this->language->get('date_format_short'));
in that file and see in your oc log if it is correct.Code: Select all
$this->registry->set('language', $language);
If it is, that value is overwritten somewhere or simply not used.
Code: Select all
error_log(....);
whenever you use this:
Code: Select all
$this->log->write(....);
you did put that statement in file catalog/controller/startup/startup.php after:
Code: Select all
$this->registry->set('language', $language);
Yes sir. Here a snippet I just copied from the startup.php file:nonnedelectari wrote: ↑Fri Jan 10, 2025 9:15 amwhenever you use this:it goes into your PHP error log which your provider can tell you where to find.Code: Select all
error_log(....);
whenever you use this:it goes into your OC's own error log which you can view in admin under system->maintenance->error logs.Code: Select all
$this->log->write(....);
you did put that statement in file catalog/controller/startup/startup.php after:right?Code: Select all
$this->registry->set('language', $language);
// Overwrite the default language object
$language = new Language($code);
$language->load($code);
$this->registry->set('language', $language);
$this->log->write('date short definition: '. $this->language->get('date_format_short'));
Then look in your PHP error log, not the webserver logs, ask your host where it is located, could be that you have an issue with your OC error log.
Double check that you have it defined in system->settings->server tab "Error Log Filename".
1. Ensure the Correct Date Format
In your catalog/language/en-gb/en-gb.php file, verify that the date_format_short value is set to m/d/Y:
Code: Select all
$['date_format_short'] = 'm/d/Y'; $['date_format_long'] = 'l dS F Y';
2. Clear Caches
After making changes to the language files:
Clear OpenCart’s modification cache: Go to Dashboard → Extensions → Modifications, and click the "Refresh" button.
Clear theme cache: If your theme uses caching, clear the cache from the theme's admin settings.
Clear browser cache to ensure you're not viewing old cached data.
3. Check Hardcoded Date Formats
Some date formats might be hardcoded in templates, controllers, or models.
Search for Hardcoded Date Formats:
Use a file search tool (e.g., grep, VS Code, or Notepad++) to look for instances of d/m/Y or date_format_short across the catalog folder.
If you find a hardcoded format like d/m/Y, replace it with your desired format (m/d/Y).
4. Add Logging to Verify Loaded Values
To confirm that the date_format_short is correctly loaded from the language file, add the following line to catalog/controller/startup/startup.php after:
Code: Select all
$this->registry->set('language', $language);
Code: Select all
$this->log->write('date short definition: ' . $this->language->get('date_format_short'));
If the log is empty, check your PHP error log. Contact your hosting provider for its location.
5. Check Your Theme
Some custom themes may override the core OpenCart logic for rendering dates.
Check Theme-Specific Files:
Look for date formatting in the following:
catalog/view/theme/<your_theme>/template/
JavaScript files (for frontend rendering).
6. Debug the Issue Further
If the above steps don’t work:
Check if the correct language file is loaded in catalog/controller/startup/startup.php.
Verify the fallback behavior in catalog/language/en-gb/en-gb.php. If a key is missing in the selected language file, OpenCart uses the default en-gb values.
7. If All Else Fails
Your issue might be related to an override or modification. Check for installed OCMOD or VQMOD modifications that could affect date handling.
Disable these modifications temporarily and test again.
You seem to be just pasting from ChatGPT and the answers aren't great.
I suggest you start writing answers yourself.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Users browsing this forum: Bing [Bot] and 16 guests