Localised Date Format is an extension written by RGB World for use with OpenCart. It can be purchased from the RGB World Store or from the OpenCart Marketplace (coming soon).
The Localised Date Format (LDF) extension allows Store Owners to quickly configure:
- How Dates are Displayed throughout an entire OpenCart store.
- How Dates are Entered into Datepicker input and search fields.
- Whether or not to display the Time.
Default OpenCart Date Formatting
With a default installation of OpenCart, Date formats are configured via a language text file. The following formats are defined in: admin/language/en-gb/en-gb.php
Code: Select all
$_['date_format_short'] = 'd/m/Y';
$_['date_format_long'] = 'l dS F Y';
$_['time_format'] = 'h:i:s A';
$_['datetime_format'] = 'd/m/Y H:i:s';
Code: Select all
$this->language->get('date_format_short')
Code: Select all
date($this->language->get('date_format_short'))
In the default OpenCart templates, the Date format used by the Datepicker is statically formatted as:
Code: Select all
data-date-format="YYYY-MM-DD"
Localised Date Format
With the Localised Date Format extension, Date formats are stored in a database and a new 'Date Formats' Menu Item is added to the OpenCart Administration panel under: System > Localisation > Date Formats. Date formats are configured via the Admin GUI.
To format a Date with the Localised Date Format API, the code would be:
Code: Select all
date($this->dateformat->get('date_format_short'))
Fixing Datepicker Format
To fix the Datepicker formatting issue described above, the following code change is required in all template files...
Find:
Code: Select all
data-date-format="YYYY-MM-DD"
Code: Select all
data-date-format="<?php echo $datepicker_date_format; ?>"