Forums / Basic Configuration / Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

Started by alwayslearning on 10 Oct 2011, 1:39 AM · Views: 2,970

Results 1 to 10 of 10
10 Oct 2011, 1:39 AM
#1
alwayslearning avatar

alwayslearning

New Zenner

Join Date:
Sep 2009
Posts:
9
Plugin Contributions:
0

Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

I was look up the tutorial on here: https://www.zen-cart.com/tutorials/index.php?article=401

I think the tutorial doesn't work with 1.3.9h. The coding has changed slightly.

Does anyone know if there is an upto date instruction for changing date format?

Thanks.

10 Oct 2011, 9:11 AM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

In what way has it changed?

20 years a Zencart User

10 Oct 2011, 8:19 PM
#3
alwayslearning avatar

alwayslearning

New Zenner

Join Date:
Sep 2009
Posts:
9
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

The english.php in 1.3.9h has a couple of additional lines of code in comparison to the tutorial guide. And so:

  1. you can not simply "find" and "replace"

  2. I could just replace the sections where there codes are the same, but I'm concerned some other parts may not work correctly, or I may some how break the thing all together.

10 Oct 2011, 8:33 PM
#4
alwayslearning avatar

alwayslearning

New Zenner

Join Date:
Sep 2009
Posts:
9
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

For example these has changed:

This is point 7 in the tutorial

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

While this is in the english.php

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

This is in point 8 of tutorial

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

  }

}

This is in english.php

 
// 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);
      }
    }
  }
11 Oct 2011, 7:43 AM
#5
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

FOR:
define('DATE_FORMAT_SPIFFYCAL', 'MM/dd/yyyy'); //Use only 'dd', 'MM' and 'yyyy' here in any order

If this is not in your current english.php file, then don't worry about it. It's likely it has been moved to another file, in which case you can use admin >>> tools >>> developer toolkit to find the file. Then open that one for editing.


FOR:
if (!function_exists('zen_date_raw')) {

Simply leave it alone...

20 years a Zencart User

12 Oct 2011, 2:41 AM
#6
alwayslearning avatar

alwayslearning

New Zenner

Join Date:
Sep 2009
Posts:
9
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

Hi Schoolboy

Thanks for the reply.

in Point 7 there are two differences:
define('PHP_DATE_TIME_FORMAT', 'm/d/Y H:i:s'); // this is used for date()
define('DATE_FORMAT_SPIFFYCAL', 'MM/dd/yyyy'); //Use only 'dd', 'MM' and 'yyyy' here in any order

I should replace everything except these two lines? But I should trace it via developers tool kit and change it that way?

In point 8:
Since everything is the same except:
if (!function_exists('zen_date_raw')) {
I should copy over everything else but leave the above line alone?

13 Oct 2011, 11:50 PM
#7
alwayslearning avatar

alwayslearning

New Zenner

Join Date:
Sep 2009
Posts:
9
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

Nudge bump. Hello

14 Oct 2011, 7:51 AM
#8
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

Please don't bump posts... We are not sitting on this forum 24 hours a day waiting for new questions. If I choose not to login to the forum for 6 months, that is MY choice.

If the instruction is that you can change MM/dd/yyyy to dd/MM/yyyy then just follow that instruction. This stuff is largely common sense. I am not a programmer, but even I can see the logic of all this...

20 years a Zencart User

15 Oct 2011, 12:50 AM
#9
alwayslearning avatar

alwayslearning

New Zenner

Join Date:
Sep 2009
Posts:
9
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

I was not expecting that.

Sorry, if I touched a nerve but thanks for your input anyway.

3 Nov 2011, 11:56 PM
#10
barbs666 avatar

barbs666

New Zenner

Join Date:
Nov 2011
Posts:
23
Plugin Contributions:
0

Re: Changing the date format from US to UK i.e mmddyyyy to ddmmyyyy

Can someone upload an english php for both 'edits' as I cant get it to work in 1.3.9h!?

Much appreciated if you do.

Thanks.