Zen Cart Logo
Forums / Basic Configuration / Featured Product date problem-I'm Stuck!

Featured Product date problem-I'm Stuck!

Locked

Views: 3,397

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
31 Mar 2010, 8:44 AM
#1
piker avatar

piker

Zen Follower

Join Date:
Nov 2009
Posts:
109
Plugin Contributions:
0

Featured Product date problem-I'm Stuck!

I'm trying to set up a few Featured Products but when I set up the dates to start and finish, then save/insert, they change to 30/11/2036 for both start and finish. I go back and edit it again and it changes again.
What would be the problem here? I'm stuck!

31 Mar 2010, 8:48 AM
#2
schoolboy avatar

schoolboy

Totally Zenned

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

Re: Featured Product date problem-I'm Stuck!

On both the ADMIN and CATALOG sides of the store, there are english.php files, inside of which the date formatting is configured.

These date formats should match, so if you are using mm/dd/yyyy in CATALOG, you should also be using mm/dd/yyyy in ADMIN.

Open these two files to see what date formats are being applied. This might be where your issue lies... I'm not sure, but we can rule it out if the formats are identical in both files.

31 Mar 2010, 9:03 AM
#3
piker avatar

piker

Zen Follower

Join Date:
Nov 2009
Posts:
109
Plugin Contributions:
0

Re: Featured Product date problem-I'm Stuck!

Thanks for the reply.

In both files (about line 31..)
it says:
define('DATE_FORMAT', 'd/m/Y'); // this is used for date()

Is that the reference you were talking about?

The admin file has this on the next line, whereas the catalog one hasn't:
define('DATE_FORMAT_SPIFFYCAL', 'dd/MM/yyyy'); //Use only 'dd', 'MM' and 'yyyy' here in any order

31 Mar 2010, 9:13 AM
#4
schoolboy avatar

schoolboy

Totally Zenned

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

Re: Featured Product date problem-I'm Stuck!

This entire section controls the date formatting:

// look in your $PATH_LOCALE/locale directory for available locales..
// on RedHat try 'en_US'
// on FreeBSD try 'en_US.ISO_8859-1'
// on Windows try 'en', or 'English'
  @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');

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

The above example is for mm/dd/yyyy and the** LOCALE** is set as US

VERY CAREFULLY compare the above with what I have put below, which is the dd/mm/yyyy format for LOCALE UK

// look in your $PATH_LOCALE/locale directory for available locales..
// on RedHat try 'en_US'
// on FreeBSD try 'en_US.ISO_8859-1'
// on Windows try 'en', or 'English'
@setlocale(LC_TIME, 'en_UK.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');

////
// Return date in raw format
// $date should be in format dd/mm/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);
      }
    }
  }

NOTE THE DIFFERENCES, particularly in these lines:

return substr($date, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4);

... and yes... there is that little addition in the ADMIN file

31 Mar 2010, 12:38 PM
#5
piker avatar

piker

Zen Follower

Join Date:
Nov 2009
Posts:
109
Plugin Contributions:
0

Re: Featured Product date problem-I'm Stuck!

Darn it, it didn't work...:shocking:

The Long Format for the Catalog file was A,B,D,Y and I changed it to A,D,B,Y ( to replicate the admin one)......this didn't seem to change anything.
The code-line that you pointed out for special attention was the same for both:(3,2 0,2 6,4) so I didn't touch them.
Should I change the Locale to your UK one? Or leave it alone?

31 Mar 2010, 1:00 PM
#6
schoolboy avatar

schoolboy

Totally Zenned

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

Re: Featured Product date problem-I'm Stuck!

Do you have time zone offset module installed?

Is your server clock functioning OK and is it properly set? Ask your host...

LOCALE should just match, but if you are UK, I'd set it to UK

31 Mar 2010, 1:13 PM
#7
piker avatar

piker

Zen Follower

Join Date:
Nov 2009
Posts:
109
Plugin Contributions:
0

Re: Featured Product date problem-I'm Stuck!

Success!
I changed the 1st substr line to :0,2 - 3,2 - 6,4 (and the next line to 6,4 - 3,2 - 0,2)
Thanks for getting me on the right track Schoolboy! Cheers.

31 Mar 2010, 1:19 PM
#8
piker avatar

piker

Zen Follower

Join Date:
Nov 2009
Posts:
109
Plugin Contributions:
0

Re: Featured Product date problem-I'm Stuck!

Just got your last post...
"Do you have time zone offset module installed?

Is your server clock functioning OK and is it properly set? Ask your host...

LOCALE should just match, but if you are UK, I'd set it to UK "

As i just stated, everythings fine now, should I still check these things out with the Host though?
Thanks again.

31 Mar 2010, 1:19 PM
#9
schoolboy avatar

schoolboy

Totally Zenned

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

Re: Featured Product date problem-I'm Stuck!

Yeah... I did warn you to pay very careful attention to the lines - particularly those...

Anyway, glad you got it sorted.

12 Apr 2010, 9:34 AM
#10
andy_gs avatar

andy_gs

Zen Follower

Join Date:
Jun 2008
Posts:
187
Plugin Contributions:
0

Re: Featured Product date problem-I'm Stuck!

So basically if i change includes/languages/english.php from:

// look in your $PATH_LOCALE/locale directory for available locales.. 
// on RedHat try 'en_US' 
// on FreeBSD try 'en_US.ISO_8859-1' 
// on Windows try 'en', or 'English' 
  @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'); 

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

to

// look in your $PATH_LOCALE/locale directory for available locales.. 
// on RedHat try 'en_US' 
// on FreeBSD try 'en_US.ISO_8859-1' 
// on Windows try 'en', or 'English' 
@setlocale(LC_TIME, 'en_UK.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'); 

//// 
// Return date in raw format 
// $date should be in format dd/mm/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); 
      } 
    } 
  }  

this should change the date formatting globally?
in both admin and catalogue?

ofc this won't change previous orders/products etc but will change any new ones going forward?

  • will this cause issues with current dated things, like voucher codes with expiration dates etc?

Andy.