Zen Cart Logo
Forums / Addon Language Packs / Changing the DOB date format customers to use DDMMYYYY

Changing the DOB date format customers to use DDMMYYYY

Locked

Views: 5,455

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
27 Nov 2008, 2:44 AM
#1
shocker avatar

shocker

Zen Follower

Join Date:
Jul 2007
Location:
Jakarta
Posts:
346
Plugin Contributions:
0

Changing the DOB date format customers to use DDMMYYYY

I'm setting up a language other than English on my site, in this case Indonesian. I need the date format to use DDMMYYY.

I've attempted to accomplish this by changing the defines in languages/MY_TEMPLATE/indonesian.php

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

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

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

The date entered as 07/02/1972 is saved as Jun 2 1972. But when redisplayed it appears in the format of DDMMYYYY (02/07/1972).

So with out changing any information and just updating the customer record repeatedly, the DOB will alternatively save as 07/02/1972 and 02/07/1972.

What needs to be changed to update and display the DOB in the format DDMMYYYY?

27 Nov 2008, 7:12 AM
#2
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Changing the DOB date format customers to use DDMMYYYY

There is also a language file in ADMIN, where you need to make the changes.

27 Nov 2008, 10:22 AM
#3
shocker avatar

shocker

Zen Follower

Join Date:
Jul 2007
Location:
Jakarta
Posts:
346
Plugin Contributions:
0

Re: Changing the DOB date format customers to use DDMMYYYY

I've checked admin/includes/languages/indonesian.php
It looks as if the file is already set to accept the DD/MM/YYYY format for Indonesian.

setlocale(LC_TIME, 'id_ID.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

define('DOB_FORMAT_STRING', 'dd/mm/yyyy');

This doesn't do the trick. Anyone know how to accomplish this?

27 Nov 2008, 10:44 AM
#4
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Changing the DOB date format customers to use DDMMYYYY

Your code currently says:

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

It shoud be:

// 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);
      }
    }
  }
27 Nov 2008, 12:09 PM
#5
shocker avatar

shocker

Zen Follower

Join Date:
Jul 2007
Location:
Jakarta
Posts:
346
Plugin Contributions:
0

Re: Changing the DOB date format customers to use DDMMYYYY

Thanks fairestcape. That worked like a charm.