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
Printable View
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
in your override copy of english.php, modify this section:
Code:@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');
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
same file:
Code:// 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!
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 ?
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/########/inde...create_account
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?
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:
1. open file includes/languages/<YOUR_TEMPLATE>/<YOUR_LANGUAGE>.php
2. find this section around line 22:
and replace with:Quote:
@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');
3. in the same file find this section around line 29:Quote:
@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');
and replace with:Quote:
// 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);
}
}
}
4. In the same file find this section around line 67:Quote:
// 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);
}
}
}
and replace with:Quote:
// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
5. In the same file find this section around line 200:Quote:
// text for date of birth example
define('DOB_FORMAT_STRING', 'dd/mm/yyyy');
and replace with:Quote:
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)');
6. Open file admin/includes/languages/<YOUR_LANGUAGE>.phpQuote:
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)');
7. Find this section around line 20:
and replace with:Quote:
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
8. In the same file find this section around line 29:Quote:
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
and replace with:Quote:
// 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);
}
}
9. In the same file find this section around line 85:Quote:
// 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);
}
}
and replace with:Quote:
// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
10. In the same file find this section around line 204:Quote:
// text for date of birth example
define('DOB_FORMAT_STRING', 'dd/mm/yyyy');
and replace with:Quote:
define('JS_DOB', '* The \'Date of Birth\' entry must be in the format: xx/xx/xxxx (month/date/year).\n');
11. In the same file find this section around line 231:Quote:
define('JS_DOB', '* The \'Date of Birth\' entry must be in the format: xx/xx/xxxx (date/month/year).\n');
and replace with:Quote:
define('ENTRY_DATE_OF_BIRTH_ERROR', ' <span class="errorText">(eg. 05/21/1970)</span>');
12. Pat yourself on the back, you're all done.Quote:
define('ENTRY_DATE_OF_BIRTH_ERROR', ' <span class="errorText">(eg. 21/05/1970)</span>');
Thanks a lot phil! :smartalec:
Great, thanks for this Phil!
This post should be referenced in the FAQs....
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?
Just a quick heads up, thank your for this post. It works a treat!
Thanks :) Worked a treat!:clap:
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.
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
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:
Template override system is not currently available for the Admin section so you need to make changes to the /admin/includes/languages/<YOUR-LANGUAGE>.php file. If you copy this file into /admin/includes/languages/<YOUR-TEMPLATE>/<YOUR-LANGUAGE>.php it will have no effect on your store.
I also wanted to say thankyou to the wonderful people in here to take their time to help others.
I have managed to change most of my dates over too (Im in Australia & therefore wanted the 'UK' format).
They are all working wonderful. The only ones I have found that have not changed are the dates that Coupons expire. My customers get a message that this coupon expirse on ... and the date is US format.
Any help is appreciated.
Thanks
Phil your a bloody legend :smartalec:
thanks Mate :hug:
That's because there are hundreds of other files still with Y-m-d format. I would leave it alone as it might have some thing to do with Mysql dates or external things like currency etc might get affected.
The only sure way of doing is to replace them in the files you see its not correct.
I am really sorry but it isn't working for me. I have redone it a few times and I don't have a CUSTOM file inmy admin section so I don't know why it is.
And I am working on my site offline so I can't link to it.
NVM, I redid it all again and it worked. Than you so much.
Excellent info Phil, Thanks, much appreciated. :cool::clap:
PS. Message To all zenners... I bought the Zen Book and it has saved me HOURS of frustration. Brilliant publication. Every novice should own it!!!!
This is incomplete. The full solution is here:
http://www.zen-cart.com/forum/showth...ht=Date+format
Fantastic thread works like a treat.
It would be great in the next release that this could be made in the admin section for the site.
Cheers
Brett
Thank you so much for this tutorial :flex:
:clap: Thanks everyone. Special thanks to Phil. I hope it's an easier process in the next update.
it took me a bit to work out i was missing the following defines:
admin english.php
and your template english.phpCode:
define('DOB_FORMAT_STRING', 'dd/mm/yyyy');
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. 21/05/1970)</span>');
Code:
define('DOB_FORMAT_STRING', 'dd/mm/yy');
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)');
its suprising how handy the "developers tool kit" can be amd finding 'the' file with 'that' text.:clap:
Hi,
I'm using Easy Populate to upload products and the date product added is not going through properly - it is using reading my UK date data as US format, so is not adding products to the newly added section.
Any ideas on how to fix this? I have changed all the references to the format in english.php for both my template and admin sections?
thanks
wonderfully and very clearly written, thank you :) made it very easy to change to Australia (dd/mm/yyyy) format..
Hi, it has worked for me to the only thing is I seem to of messed my register page up as you can see from the pic below the words have gone for the date of birth and, im not sure but i think ive messed my tables up as they are no longer alined.
http://www.truliebliss.com/page.jpg
Hope you guys can help me with this.
Thanx
I want to set the UK date on my site but when following this on my test Site it worked for the signup form and such. But when running a sales report i get an error one of the dates you entered is not valid.
i did try changing the date format in the stats_sales_report.php file but that didn’t make any difference.
I’m thinking its the SQL database that my be the root of this but don’t know :unsure:.
Anyone else seen this and fixed it?
Gawd... why did I bother? LOL
can't get into admin now, have checked and re-checked...
I get this message: Parse error: syntax error, unexpected T_STRING in /home/getbuck/public_html/admin/includes/languages/english.php on line 186
which should refer to one of these first lines here (assuming phil's line numbers are correct!)
All I'm seeing is a missing * (possibly) where it defines company name???PHP Code:
define('PLEASE_SELECT', 'Please select ...');
define('TYPE_BELOW', 'Type a choice below ...');
define('ENTRY_COMPANY', 'Company Name:');
define('ENTRY_COMPANY_ERROR', 'Please enter a company name.');
define('ENTRY_COMPANY_TEXT', '');
define('ENTRY_GENDER', 'Salutation:');
define('ENTRY_GENDER_ERROR', 'Please choose a salutation.');
define('ENTRY_GENDER_TEXT', '*');
define('ENTRY_FIRST_NAME', 'First Name:');
define('ENTRY_FIRST_NAME_ERROR', 'Is your first name correct? Our system requires a minimum of ' . ENTRY_FIRST_NAME_MIN_LENGTH . ' characters. Please try again.');
define('ENTRY_FIRST_NAME_TEXT', '*');
define('ENTRY_LAST_NAME', 'Last Name:');
define('ENTRY_LAST_NAME_ERROR', 'Is your last name correct? Our system requires a minimum of ' . ENTRY_LAST_NAME_MIN_LENGTH . ' characters. Please try again.');
define('ENTRY_LAST_NAME_TEXT', '*');
define('ENTRY_DATE_OF_BIRTH', 'Date of Birth:');
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)');
I have the "requires company name" for login details set to off...
anyone?? Its rather late here in aus and i have almost reached the limit of my patience with this particulare problem - I'm no net wiz, so any help greatly appreciated!!
Right... feeling pretty stupid right about now, but have figured it out nonetheless...
Thanks Phill, you are as good as they say ;):clap:
I've got the same problem
I edited admin\includes\languages\english.php
and
includes\languages\english.php
Still getting the warning "Is your birth date correct? Our system requires the date in this format: MM/DD/YYYY (eg 05/21/1970)" after completing new account registration
"I bought the Zen Book and it has saved me HOURS of frustration. Brilliant publication. Every novice should own it!!!! "
I second this.
ok, i have gone thru all of these changes to the codes but there are a couple of bits of code that I dont seem to have the same as the the one shown.
number10
define('JS_DOB', '* The \'Date of Birth\' entry must be in the format: xx/xx/xxxx (month/date/year).\n');
11
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)');
define('ENTRY_EMAIL_ADDRESS', 'Email Address:');
define('ENTRY_EMAIL_ADDRESS_ERROR', 'Is your email address correct? It should contain at least ' . ENTRY_EMAIL_ADDRESS_MIN_LENGTH . '
www. stitchwith.me
Just a quick tip from someone who always manages to screw things up.
1. Make a copy of the original file and call it something like english.old
2. Once you have your modified file working correctly make a copy called something like english.bak
Now if you screw up or overwrite the file with an update you can retrieve all your hard work!
Late in the day I know but I too would like to add my thanks to Phil for laying this out so clearly.
Just finished the edit and a check, all seems to be ok.
Thanks again
Guy
You are a legend!!!!!!!!!!
this is great
Nonsense. Dates are held in the database in the internal MySQL format (aka ISO International standard). The database neither knows nor cares how they will be formatted for display on pages or in emails. That is determined by the relevant language file as described above, which is the only proper way to change date formats.
Thanks Phil - I knew it wasn't easy!
Great set of instructions - simple and easy to follow. Thanks Phil.
a little bit of other!
Where can I translate the name of the months appearing on the index of my website? I've only found one language file containing them in the admin/includes/languages folder, but it has no effect, when I change them there.
Thank you
:bigups:
just to let people know..
IF you wish to change the date format to upload with EASYPOPULATE
admin>configuration>easypopulate>upload file date format
Just wanted to say thank you so much for this tutorial very much appreciated :).
Hello.
This one could be very useful, however I have one slight problem with it
I don't have a "/template-i'm-using/" folder inside the includes/languages/ folder :lookaroun :lookarounQuote:
Phil says:
1. open file includes/languages/<YOUR_TEMPLATE>/<YOUR_LANGUAGE>.php
Can I create the f.i. "theme101" folder inside the languages and also copy the "slovenian.php" from \includes\languages folder?
You will need to look in the language file under /languages/english[or whatever language your using].php
Look for:
/** templates/*.php */
DEFINE('_ISO','charset=iso-8859-1');
DEFINE('_DATE_FORMAT','l, F d Y'); //Uses PHP's DATE Command Format - Depreciated
/**
* Modify this line to reflect how you want the date to appear in your site
*
*e.g. DEFINE("_DATE_FORMAT_LC","%A, %d %B %Y %H:%M"); //Uses PHP's strftime Command Format
*/
DEFINE('_DATE_FORMAT_LC',"%A, %d %B %Y"); //Uses PHP's strftime Command Format
DEFINE('_DATE_FORMAT_LC2',"%A, %d %B %Y %H:%M");
and make the necessary alterations to have the date/time formatted as you wish.
Mengembalikan Jati Diri Bangsa|
Kenali Dan Kunjungi Objek Wisata Di Pandeglang
Worked for me :D
Thanks for taking the time to post the instructions step by step.
I have bookmarked this page for future sites.
This should be a feature in the Config section of the site.
But why when I complete signing up I got a blank page although the registration successfully made in !!
I have changed the files as stated but the date is still in the wrong order on the invoice status table (bottom left)
I have the time_zone_offset_v1-3-8a module installed could this be the problem? - the date seems fine everywhere else.
It WORKS!!
You have missed something in the instructions
or not used the overides correctly
or your files have not been uploaded correctly
(maybe it is working and you need to clear your browsers cache)
Lots of possible things that you have done wrong
It needs to be altered both in the admin and catalog sections.
You will need to go thru the instructions step by step and confirm each correction as you go
Also there are some obscure / little used dates that are not fixed.
If you need these you will have to track them down yourself
Which date(s) are you looking at that is(are) not correct?
Thanks heaps. Should definately be placed in the FAQ section or an option for Admin to change from US to UK/AUS ways.
Kind Regards
Another Happy Zenner :)
Thank you for the easy to follow and 100% working instructions :clap:.
Zen-Cart Admin Staff, please add these info to the FAQ page!
Best Regards,
They already are in the FAQ, with some minor corrections if I remember correctly.
For anyone interested I would like to add and update to the thread on changing date format to uk.
The line from the origional english.php file whether you change it in Admin/languages or
Admin/languages/custom
reads
@setlocale(LC_TIME, 'en_US.ISO_8859-1');
can be changed to
@setlocale(LC_TIME, 'en_GB.ISO_3166-1');
for proper UK definition.