Zen Cart Logo
Forums / General Questions / Date Format for Product Availability

Date Format for Product Availability

Locked

Views: 2,081

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
19 Mar 2010, 2:56 PM
#1
jorsara avatar

jorsara

New Zenner

Join Date:
Oct 2009
Posts:
89
Plugin Contributions:
0

Date Format for Product Availability

Hello All,

Althought my date format in english.php in admin and catalog side seems to be set to US english properly, it shows in a day, month, and year format on the product when I set the availability date. For example June 15, 2010. It acutally shows; "This product will be in stock on Tuesday 15 June, 2010."

Can anyone explain how to correct this please? Your assistance is greatly appreciated.

Jorsara

20 Mar 2010, 2:54 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Date Format for Product Availability

This is using a function to set the date display from the template file:

/includes/templates/template_default/templates/tpl_product_info_display.php

Line #209 : <p id="productDateAvailable" class="productGeneral centeredContent"><?php echo sprintf(TEXT_DATE_AVAILABLE, zen_date_long($products_date_available)); ?></p>

21 Mar 2010, 7:45 AM
#3
jorsara avatar

jorsara

New Zenner

Join Date:
Oct 2009
Posts:
89
Plugin Contributions:
0

Re: Date Format for Product Availability

Thank you for the reply.

When I change the format of the following;
if ($products_date_available > date('Y-m-d H:i:s')) { to if ($products_date_available > date('Y-d-m H:i:s')) { the message disappear. Is there a way to make it work to show the proper date format in the message as such; " This product will be available on May 12 2010 instead of " This product will be in stock on Wednesday 12 May, 2010." ?

Thank you.

21 Mar 2010, 1:27 PM
#4
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Date Format for Product Availability

You would edit the TEXT_DATE_AVAILABLE define in includes/languages/english/YOUR_TEMPLATE/product_info.php

21 Mar 2010, 4:56 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Date Format for Product Availability

Actually, if you look at the way the date is pulled in, the date is actually:
$products_date_available

Then, that date is processed by a function to give the current display:
zen_date_long($products_date_available)

You can processes that date:
$products_date_available

in another manner or check the functions that work on dates ...

Looking in the file:
/includes/functions/functions_general.php

and searching on:
date

will show you several functions built into Zen Cart ... and you can always use your own ...

The constant:
TEXT_DATE_AVAILABLE

is just bringing in the "text" and placing the "date" on the end of it ...

21 Mar 2010, 5:32 PM
#6
jorsara avatar

jorsara

New Zenner

Join Date:
Oct 2009
Posts:
89
Plugin Contributions:
0

Re: Date Format for Product Availability

Thank you Steve for the info.

21 Mar 2010, 5:37 PM
#7
jorsara avatar

jorsara

New Zenner

Join Date:
Oct 2009
Posts:
89
Plugin Contributions:
0

Re: Date Format for Product Availability

Ajeh,

Thank you for the information. However, I still don't know how to change the date so The American People can understand it properly. In the file /includes/functions/functions_general.php there are number of formats that needs to be edited and I honstly don't know how. I apologize for my ignorance.
These are the information I see. Where exactly can I change them to have it correctly display, for instance April 15, 2010 and not the other way around?

// Output a raw date string in the selected locale date format

// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS

function zen_date_long($raw_date) {

if ( ($raw_date == '0001-01-01 00:00:00') || ($raw_date == '') ) return false;



$year = (int)substr($raw_date, 0, 4);                    What do these numbers mean?

$month = (int)substr($raw_date, 5, 2);

$day = (int)substr($raw_date, 8, 2);

$hour = (int)substr($raw_date, 11, 2);

$minute = (int)substr($raw_date, 14, 2);

$second = (int)substr($raw_date, 17, 2);

Thank you.

21 Mar 2010, 6:17 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Date Format for Product Availability

If you look in that function, you will see the define for:
DATE_FORMAT_LONG

If you peek at your language file you will find where that is defined ...

Using your templates and overrides for your language file, you can adjut the definition for the define for:
DATE_FORMAT_LONG

21 Mar 2010, 6:34 PM
#9
jorsara avatar

jorsara

New Zenner

Join Date:
Oct 2009
Posts:
89
Plugin Contributions:
0

Re: Date Format for Product Availability

Okay, this is what I see in the function_general.php

return strftime(DATE_FORMAT_LONG, mktime($hour,$minute,$second,$month,$day,$year));

now, are you talking about this file? where I need to change teh format?

/public_html/includes/languages/english/CUSTOM

If not, where exactly is the file in the languages where I need to change the "define"?

Thank you again.

21 Mar 2010, 6:52 PM
#10
jorsara avatar

jorsara

New Zenner

Join Date:
Oct 2009
Posts:
89
Plugin Contributions:
0

Re: Date Format for Product Availability

Hello Ajeh,

disregard the last update. I finally figured it. It was in the english.php and I just reversed the %b - %B to %B %d as follow;

define('DATE_FORMAT_LONG', '%A %B %d, %Y'); // this is used for strftime()

It is displaying them correctly now.

Thank you again.

21 Mar 2010, 8:48 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Date Format for Product Availability

You are most welcome ... glad that you were able to work your way through and figure out exactly what setting you needed for your date display ... :smile: