New Zenner
- Join Date:
- Feb 2007
- Posts:
- 20
- Plugin Contributions:
- 0
How do I change the Date format?
I wish to change the date from the default "US Format MM/DD/YYYY" to the "UK Format DD/MM/YYYY".
Is there an easy solution?
BR
Toby
Views: 108,760
New Zenner
I wish to change the date from the default "US Format MM/DD/YYYY" to the "UK Format DD/MM/YYYY".
Is there an easy solution?
BR
Toby
Totally Zenned
in your override copy of english.php, modify this section:
@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');
Neville
An assumption is what you arrive at when you get tired of thinking...
New Zenner
Hi
I made the following changes to my english.php:
@setlocale(LC_TIME, 'en_US.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');
Is this everything?
When I go to the create account page on my site - it still says for "Date of Birth" the system requires the MM/DD/YYYY Format..
I hope you can help?
Kind Regards
Toby
Totally Zenned
same file:
// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
Neville
An assumption is what you arrive at when you get tired of thinking...
Zen Follower
bunyip:
same file:
// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
Im having the same trouble...maybe u can help?
My examples show that it should be: 21/05/1970, but when user inputs that it comes up **Is your birth date correct? Our system requires the date in this format: DD/MM/YYYY (eg 21/05/1970)
**I have done this in the php as u indicated but it still only works when usa format is inputed.
Could this be from me having overrides done wrong?
I have the english php in the languages folder and the same changes on another copy of the english php in my languages/custom.
Thanks for lookin!
v1.5.6c
https://partydudes.co.nz
New Zenner
I am having the same problem. I have changed all the code about and also the error messages but it still says UK is wrong when i try to enter it. Can any one give me any advise ?
Totally Zenned
Crazy:
I am having the same problem. I have changed all the code about and also the error messages but it still says UK is wrong when i try to enter it. Can any one give me any advise ?
Remember to alter the english.php in the admin & the catalog sections.
You may have edited the wromg one. You need to edit BOTH
Contribs: - Time Zone Fix/Offset ■ Google Adsense ■ betterCategoriesEzInfo ■ Multi Cross Sell
New Zenner
No i tried its please try and sign up ? i editted so that the error messages and the examples are correct but it won't accepted dd/mm/yyyy
http://crazy-hosting.co.uk/butt/index.php?main_page=create_account
Zen Follower
I'm having a little trouble changing the date format to dd/mm/yyyy. I managed to get it all changed and it works but in the create account and my account information the example still says 05/21/1970. But it is working in the correct format if you enter it was 05/21/1970 it returns an error saying it should be in the format 05/21/1970.
can anyone help me change the example text please?
Totally Zenned
Phil020782:
I'm having a little trouble changing the date format to dd/mm/yyyy. I managed to get it all changed and it works but in the create account and my account information the example still says 05/21/1970. But it is working in the correct format if you enter it was 05/21/1970 it returns an error saying it should be in the format 05/21/1970.
can anyone help me change the example text please?
You need to edit admin\includes\languages\english.php
and
includes\languages\english.php
(edit and copy this one into your override directory)
includes\languages\YOUR_TEMPLATE\english.php
Contribs: - Time Zone Fix/Offset ■ Google Adsense ■ betterCategoriesEzInfo ■ Multi Cross Sell
Zen Follower
Thanks gilby, I eventually got it working.
For anyone else who wants to know here is what I done step by step to change the date format from mm/dd/yyyy to dd/mm/yyyy:
open file includes/languages/<YOUR_TEMPLATE>/<YOUR_LANGUAGE>.php
find this section around line 22:
@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');
and replace with:
@setlocale(LC_TIME, 'en_US.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');
// 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:
// 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, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4);
} else {
return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2);
}
}
}
// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
and replace with:
// text for date of birth example
define('DOB_FORMAT_STRING', 'dd/mm/yyyy');
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:
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 file admin/includes/languages/<YOUR_LANGUAGE>.php
Find this section around line 20:
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
and replace with:
setlocale(LC_TIME, 'en_US.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
// 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:
// 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, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4);
} else {
return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2);
}
}
// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
and replace with:
// text for date of birth example
define('DOB_FORMAT_STRING', 'dd/mm/yyyy');
define('JS_DOB', '* The 'Date of Birth' entry must be in the format: xx/xx/xxxx (month/date/year).\n');
and replace with:
define('JS_DOB', '* The 'Date of Birth' entry must be in the format: xx/xx/xxxx (date/month/year).\n');
define('ENTRY_DATE_OF_BIRTH_ERROR', ' <span class="errorText">(eg. 05/21/1970)</span>');
and replace with:
define('ENTRY_DATE_OF_BIRTH_ERROR', ' <span class="errorText">(eg. 21/05/1970)</span>');
New Zenner
Phil020782:
Thanks gilby, I eventually got it working.
For anyone else who wants to know here is what I done step by step to change the date format from mm/dd/yyyy to dd/mm/yyyy:
etc
That all worked sweet, thanks a lot.
Zen Follower
Thanks a lot phil! :smartalec:
The greatest pleasure in life is doing what people say you cannot do.
Check on www.WebExtremeCustomiser.com for my modules (free contribution):
AJAX Image Swapper
AJAX Banner Swapper
Fixed Navigation
New Zenner
Great, thanks for this Phil!
This post should be referenced in the FAQs....
=========================================
The Organic Store
New Zenner
I want to change year to Buddhism. I know that I have to add +543 after some function to be corrected. However, I don't know how or where can I edit it?
New Zenner
Just a quick heads up, thank your for this post. It works a treat!
New Zenner
Thanks :) Worked a treat!:clap:
New Zenner
Yes that works very well, thank you,
I'm not sure if its planned but wouldnt it be great to have a option in admin to change between US and UK date formats.
New Zenner
I just wanted to say a HUGE thanks for this Phil!
As someone with no knowledge of programming and new to Zen cart (the person who designed my website chose to use it)
Your step by step instructions were just what I needed to be successful at making the change I wanted to!!
A godsend for a beginner!!
Thanks so much! :clap:
Debbie
New Zenner
This was great info, thanks. However, I have been wading through tutorials and little warnings pop up now and again about making sure your files don't get over-ridden during an update. For this reason (AT STEP 6) I copied the file admin/includes/languages/<YOUR_LANGUAGE>.php into
admin/includes/languages/<YOUR_TEMPLATE>/<YOUR_LANGUAGE>.php and made my changes there.
It seems to work and I don't know if I'm just being over cautious or not.
:smile:
Tell staff why this post should be reviewed.