在世界各地,使用很多种不同的日期格式,改变其中任何一种方式大致相同。在本教程中,我们将展示如何修改美国的默认格式的dd/ mm / yyyy格式用于大多数其他英语国家和其他语种的国家。
1、打开文件
includes/languages/<YOUR_TEMPLATE>/<YOUR_LANGUAGE>.php
(如果这个文件不存在,通过复制includes/languages/<YOUR_LANGUAGE>.php
文件,在本地创建一个。)
2、找到这个章节:
@setlocale(LC_TIME,
'en_US.ISO_8859-1');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');
替换为:
@setlocale(LC_TIME,
'en_GB.ISO_8859-1');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');
3、在同一个文件中,找到这节:
// Return date in raw
format// $date should be in format mm/dd/yyyy// raw date is in format YYYYMMDD,
or DDMMYYYYif (!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); } }}
替换为:
// Return date in raw
format// $date should be in format dd/mm/yyyy// raw date is in format YYYYMMDD,
or DDMMYYYYif (!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); } }}
4、在同一文件中,找到这节:
// text for date of birth
exampledefine('DOB_FORMAT_STRING', 'mm/dd/yyyy');
替换为:
// text for date of birth
exampledefine('DOB_FORMAT_STRING', 'dd/mm/yyyy');
5、在同一文件中,找到这节:
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)');
替换为:
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)');
6、打开文件 admin/includes/languages/<YOUR_LANGUAGE>.php
这个文件目前不能被覆盖,你需要直接编辑该文件,如果你升级到Zen Cart的最新版本则要小心重新申请修改。
7、找到这节:
setlocale(LC_TIME,
'en_US.ISO_8859-1');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
替换为:
setlocale(LC_TIME,
'en_GB.ISO_8859-1');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
8、在同一文件中找到这一节:
// Return date in raw
format// $date should be in format mm/dd/yyyy// raw date is in format YYYYMMDD,
or DDMMYYYYfunction 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);
}}
替换为:
// Return date in raw
format// $date should be in format dd/mm/yyyy// raw date is in format YYYYMMDD,
or DDMMYYYYfunction 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);
}}
9、在同一文件中,找到这一节:
// text for date of birth
exampledefine('DOB_FORMAT_STRING', 'mm/dd/yyyy');
替换为:
// text for date of birth
exampledefine('DOB_FORMAT_STRING', 'dd/mm/yyyy');
10、在同一文件中找到这一节
define('JS_DOB', '* The
'Date of Birth' entry must be in the format: xx/xx/xxxx
(month/date/year).n');
替换为:
define('JS_DOB', '* The
'Date of Birth' entry must be in the format: xx/xx/xxxx
(date/month/year).n');
11、在同一文件中找到这节:
define('ENTRY_DATE_OF_BIRTH_ERROR',
' <span class="errorText">(eg.
05/21/1970)</span>');
替换为
define('ENTRY_DATE_OF_BIRTH_ERROR',
' <span class="errorText">(eg.
21/05/1970)</span>');
到此为止,你已经完成了! |