Localised Date Format - Documentation
Posted: Mon May 29, 2017 12:20 am
Localised Date Format (LDF) Extension
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:
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
The format (text) is then accessed from the Controller via the language object.
To format a Date, the code would be:
Default Datepicker Format
In the default OpenCart templates, the Date format used by the Datepicker is statically formatted as:
Due to the use of static text in the template files, Changing the definition of 'date_format_short' does NOT change the date format that is used by the Datepicker. The Datepicker format remains "YYYY-MM-DD". Thus, dates entered into Datepicker input fields must always be entered as 2017-05-27. The only dates that are displayed according to the language setting are the dates that appear in List views.
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:
So, the basic change is to replace: "$this->language->get('date_format_short')" with "$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:
Replace with:
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; ?>"