- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
ZenCart. How to change dates format
February 13, 2015
This tutorial will show you how to change the default date US format (month/day/year) to European (day/month/year) in ZenCart.
ZenCart. How to change dates from US format to European (day/month/year)
We’ll edit two Zen Cart language files to make this change.
-
Go to ZenCart installation root and open includes/languages/your-language.php file (if this file doesn’t exist, create it by copying the file admin/includes/languages/your-language.php to this location) and find this section:
@setlocale(LC_TIME, 'en_US'); define('DATE_FORMAT_SHORT', '%m/%d/%Y'); // this is used for strftime() define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime() define('DATE_FORMAT', 'm/d/Y'); // this is used for date() define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');
replace it with the following:
@setlocale(LC_TIME, 'en_GB'); define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // this is used for strftime() define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime() define('DATE_FORMAT', 'd/m/Y'); // this is used for date() define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');
- in the same file find this section:
// Return date in raw format // $date should be in format mm/dd/yyyy // raw date is in format YYYYMMDD, or DDMMYYYY if (!function_exists('zen_date_raw')) { function zen_date_raw($date, $reverse = false) { if ($reverse) { return substr($date, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4); } else { return substr($date, 6, 4) . substr($date, 0, 2) . substr($date, 3, 2); } } }
and replace with the following:
// Return date in raw format // $date should be in format dd/mm/yyyy // raw date is in format YYYYMMDD, or DDMMYYYY if (!function_exists('zen_date_raw')) { function zen_date_raw($date, $reverse = false) { if ($reverse) { return substr($date, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4); } else { return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2); } } }
- In the same file find this section:
// text for date of birth example define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
and replace with the following:
// text for date of birth example define('DOB_FORMAT_STRING', 'dd/mm/yyyy');
- In the same file find this section:
define('ENTRY_DATE_OF_BIRTH_ERROR', 'Is your birth date correct? Our system requires the date in this format: MM/DD/YYYY (eg 05/21/1970)'); define('ENTRY_DATE_OF_BIRTH_TEXT', '* (eg. 05/21/1970)');
and replace with the following:
define('ENTRY_DATE_OF_BIRTH_ERROR', 'Is your birth date correct? Our system requires the date in this format: DD/MM/YYYY (eg 21/05/1970)'); define('ENTRY_DATE_OF_BIRTH_TEXT', '* (eg. 21/05/1970)');
Open admin/includes/languages/your-language.php file.
Find this section:
setlocale(LC_TIME, 'en_US'); define('DATE_FORMAT_SHORT', '%m/%d/%Y'); // this is used for strftime() define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime() define('DATE_FORMAT', 'm/d/Y'); // this is used for date() define('PHP_DATE_TIME_FORMAT', 'm/d/Y H:i:s'); // this is used for date() define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S'); define('DATE_FORMAT_SPIFFYCAL', 'MM/dd/yyyy'); //Use only 'dd', 'MM' and 'yyyy' here in any order
and replace with the following:
setlocale(LC_TIME, 'en_GB'); define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // this is used for strftime() define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime() define('DATE_FORMAT', 'd/m/Y'); // this is used for date() define('PHP_DATE_TIME_FORMAT', 'd/m/Y H:i:s'); // this is used for date() define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S'); define('DATE_FORMAT_SPIFFYCAL', 'dd/MM/yyyy'); //Use only 'dd', 'MM' and 'yyyy' here in any order
- In the same file find this section:
// Return date in raw format // $date should be in format mm/dd/yyyy // raw date is in format YYYYMMDD, or DDMMYYYY function zen_date_raw($date, $reverse = false) { if ($reverse) { return substr($date, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4); } else { return substr($date, 6, 4) . substr($date, 0, 2) . substr($date, 3, 2); } }
and replace with the following:
// Return date in raw format // $date should be in format dd/mm/yyyy // raw date is in format YYYYMMDD, or DDMMYYYY function zen_date_raw($date, $reverse = false) { if ($reverse) { return substr($date, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4); } else { return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2); } }
- In the same file find this section:
// text for date of birth example define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
and replace with the following:
// text for date of birth example define('DOB_FORMAT_STRING', 'dd/mm/yyyy');
- In the same file find this section:
define('JS_DOB', '* The \'Date of Birth\' entry must be in the format: xx/xx/xxxx (month/date/year).\n');
and replace with the following:
define('JS_DOB', '* The \'Date of Birth\' entry must be in the format: xx/xx/xxxx (date/month/year).\n');
- In the same file find this section:
define('ENTRY_DATE_OF_BIRTH_ERROR', ' (eg. 05/21/1970)');
and replace with the following:
define('ENTRY_DATE_OF_BIRTH_ERROR', ' (eg. 21/05/1970)');
Done! That’s all! Now all dates on your site will be displayed in European format.
Feel free to check the detailed video tutorial below:
ZenCart. How to change dates from US format to European (day/month/year)