| |

To change the date format used in osCommerce (when members create their account) from mm/dd/yyyy to dd/mm/yyyy, you simply need to change the main language file. The file should be located at catalog/includes/languages/<language_name>.php (for example: catalog/includes/languages/english.php).

I found the solution at the osCommerce forums in this thread, but it is missing a couple of things that were overlooked.

Change the file from (around line 21):

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');

////
// 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, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4);
  } else {
    return substr($date, 6, 4) . substr($date, 0, 2) . substr($date, 3, 2);
  }
}

To:


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('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');

////
// 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);
}
}

You should also change (on about line 61):

From

// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');

To

// text for date of birth example
define('DOB_FORMAT_STRING', 'dd/mm/yyyy');

The other change you need to make is on lines 175 and 176.

From:

define('ENTRY_DATE_OF_BIRTH_ERROR', 'Your Date of Birth must be in this format: MM/DD/YYYY (eg 05/21/1970)');
define('ENTRY_DATE_OF_BIRTH_TEXT', '* (eg. 05/21/1970)');

To:

define('ENTRY_DATE_OF_BIRTH_ERROR', 'Your Date of Birth must be in this format: DD/MM/YYYY (eg 21/05/1970)');
define('ENTRY_DATE_OF_BIRTH_TEXT', '* (eg. 21/05/1970)');

Thats about it...

Trackback URL for this post:

http://www.nickschoonens.com/trackback/12

Works Great!

Thanks heaps mate...easiest instructions ever!

osCommerce

Hey Nick,

How do you find osCommerce to use in general? When I was working with it I must admit that I found it to be a little confusing. Just out of interest :)

osCommerce

Overall, I think osCommerce is great at doing what it does, being a generic e-commerce shop. When you start needing to do anything that isn't built into core it becomes a handful, because installing contributions requires you to actually modify code of the core files. I guess I am used to Drupal's way of handling modules, which requires no coding what-so-ever, and in the new version it even updates the database automatically. That's why I'll be focussing more on developing Drupal sites from now on...