Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Change date format to uk: DD/MM/YYYY


Guest

Recommended Posts

Hi, all the dates my site are all set to the usa style: MM/DD/YYYY (i.e date of birth etc)

 

How do i change it to the UK format (DD/MM/YYYY) ?

 

Thanx, Mark.

Link to comment
Share on other sites

Edit your includes/languages/english.php file for the following settings:

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 strftime()
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
function tep_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);
}
}

// if USE_DEFAULT_LANGUAGE_CURRENCY is true, use the following currency, instead of the applications default currency (used when changing language)
define('LANGUAGE_CURRENCY', 'GBP');

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Thanx, i tried that, not too sure how much it's changed but when i click "create account" (create_account.php) it still asks for date of birth in USA format: MM/DD/YYY ...

Link to comment
Share on other sites

I've done it now! lol

 

 

Thanx :)

 

Thanx, i tried that, not too sure how much it's changed but when i click "create account" (create_account.php) it still asks for date of birth in USA format: MM/DD/YYY ...
Link to comment
Share on other sites

Sorry for being thick, do you just make these alterations using Notepad to open the file??

Hi Dave

 

In my limited experience I found that Notepad works fine. There are other programs available, I use Dreamweaver to edit the code now. Notepad will do the job just fine for the odd bit here and there though. Hope that helps.

 

Scott

Link to comment
Share on other sites

Dreamweaver allows you to edit both text, HTML, and PHP although syntax highlighting and other features are not provided for PHP.

 

It is a great application and and very useful for troubleshooting layout issues especially with all of the nested tables that osC uses.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

As an addition to my previous reply.

 

The following dates are still not dd/mm/yyyy

 

Admin Panel/Customers/Account Created

Admin Panel/Orders/Date Purchased

 

Also I created a dummy new account, it accepted my birth date as 27/03/1958 ( even thou prompt still showed it as mm/dd/yyyy ).

 

Check in Admin Panel/Customers for that new account, and it shows DOB as 03/27/1958.

 

There is a lot more coding to be done to change everything correctly.

 

Any ideas, somebody must have done it before.

Link to comment
Share on other sites

Yes but as I already have customers, orders etc with date of birth etc etc that are set up as mm/dd/yy, using that bit of code now upsets my system.

You will need to right a PHP script to go through all of the appropriate fields in all of the affected tables to correct the currently stored value to the new format. Otherwise you will have to revert and live with the old US format.

 

Did you change the settings in both the includes/languages/english.php and the admin/includes/languages/english.php files?

 

It sounds like you only did the catalog side.

 

In regards to the birth date text on the create account.php page, that is a hard-coded text value. Look in the includes/languages/english.php file for the text and change it to the appropriate value.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Would I need to mod the MySQL database ???

Editting the two english.php files is the only thing you need to do to change the date format, and I dont think this would upset your shop in any way.

 

Ken

commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).

over 20 years of computer programming experience.

Link to comment
Share on other sites

added to my post above, a programming languange such as php should, and indeed does, have the very basic function, which osc obviousely makes use of, to display a date in any one of the formats, e.g., the UK date format, regardless how the raw date data is stored in the database (which, by the way, is 'yyyy/mm/dd'). Or you prove me wrong?

 

Ken

commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).

over 20 years of computer programming experience.

Link to comment
Share on other sites

added to my post above, a programming languange such as php should, and indeed does, have the very basic function, which osc obviousely makes use of, to display a date in any one of the formats, e.g., the UK date format, regardless how the raw date data is stored in the database (which, by the way, is 'yyyy/mm/dd'). Or you prove me wrong?

 

Ken

 

It always worries me, date and time, in MySQL databases.

 

I've changed 'datatypes' before and made a right pigs ear of it.

Link to comment
Share on other sites

It always worries me, date and time, in MySQL databases.

 

I've changed 'datatypes' before and made a right pigs ear of it.

What I really meant was that you did not need to change anything in the db. PHP & osc would take care of it, provided you tell it what format you want via the two english.php files. If you cant achieve what you want by just editting these two files, then post back here. I honestly dont believe it.

 

Ken

commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).

over 20 years of computer programming experience.

Link to comment
Share on other sites

Just changing the settings in the 2 english.php files has always worked for me as well.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Just changing the settings in the 2 english.php files has always worked for me as well.

 

You are right, it works OK.

 

And there are only 3 other occurances of hard coded eg 05/21/1990 that need to be changed, and they occur in the same 2 english.php files.

 

Many thanks.

Link to comment
Share on other sites

And there are only 3 other occurances of hard coded eg 05/21/1990 that need to be changed, and they occur in the same 2 english.php files.

As far as I can recall that is true, unless you have added some contributions and/or custom modifications that also contain hard-coded dates.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...