Page 1 of 1

Format Special Date

Posted: Fri Nov 25, 2011 12:37 pm
by Oistacus
Hi Brent,
is there a method to set this date in european format ( dd mm yyyy )?
Immagine.JPG
Immagine.JPG (25.78 KiB) Viewed 13433 times
Ois

Re: Format Special Date

Posted: Fri Nov 25, 2011 2:57 pm
by Brent
If you want to manually change it, it is product.tpl

Code: Select all

		<?php if (($product['special_price'] > '$0.00' ) && date('Y-m-d') >= $product['sale_start_date'] && date('Y-m-d') <= $product['sale_end_date']) { ?><br>	
		  <?php echo "<b>".$text_date."</b><br>"; ?>
		  <?php echo "&nbsp;&nbsp;".$text_sale_start.date("F-d-Y",strtotime($product['sale_start_date'])); ?><br>
		  <?php echo "&nbsp;&nbsp;".$text_sale_end.date("F-d-Y",strtotime($product['sale_end_date'])); ?><br>
		<?php } ?>
Just change the F-d-y to whatever format you want.

Re: Format Special Date

Posted: Fri Nov 25, 2011 3:33 pm
by Oistacus
Hi ,
I thinked this , but the language remain in english always

Re: Format Special Date

Posted: Fri Nov 25, 2011 3:38 pm
by Brent
Let me make some changes using the new date class.

Re: Format Special Date

Posted: Fri Nov 25, 2011 3:45 pm
by Oistacus
Meanwhile I made ​​the change .

Re: Format Special Date

Posted: Fri Nov 25, 2011 5:59 pm
by Brent
In catalog/controller/product.php at line 20, add the $dates initialization.

Code: Select all

function index() { 
		$cart     =& $this->locator->get('cart');
		$currency =& $this->locator->get('currency');
		$dates    = $this->locator->get('dates');  //***** 
		$this->dimension=& $this->locator->get('dimension');
At about line 218 add the 2 view set lines.

Code: Select all

if($product_info['special_price'] >0 && date('Y-m-d') >= $product_info['sale_start_date'] && date('Y-m-d') <= $product_info['sale_end_date']){
			    $number_days = intval((strtotime($product_info['sale_end_date']) - time())/86400);
			    $days_remaining = $language->get('days_remaining', ($number_days ? $number_days : 1));   
				$view->set('sale_start',$dates->getDate("F-d-Y", strtotime($product_info['sale_start_date']))); //***** 
				$view->set('sale_end', $dates->getDate("F-d-Y", strtotime($product_info['sale_end_date']))); //***** 
			}
In product.tpl at lines 169 and 170, change these 2 lines to use the sales_start and sales_end variables which not contain language formatted text.

Code: Select all

<?php if (($product['special_price'] > '$0.00' ) && date('Y-m-d') >= $product['sale_start_date'] && date('Y-m-d') <= $product['sale_end_date']) { ?><br>	
		  <?php echo "<b>".$text_date."</b><br>"; ?>
		  <?php echo "&nbsp;&nbsp;".$text_sale_start.$sale_start; ?><br>
		  <?php echo "&nbsp;&nbsp;".$text_sale_end.$sale_end; ?><br>
		<?php } ?>
Make sure you have updated the language/Italian/italian.php to reflect the new dates as per the english.

Re: Format Special Date

Posted: Sat Nov 26, 2011 6:14 am
by Brent
In the product.php, use this instead if you like. It will format as per your language file.

Code: Select all

$view->set('sale_start',$dates->getDate($language->get('date_format_short'), strtotime($product_info['sale_start_date'])));
				$view->set('sale_end', $dates->getDate($language->get('date_format_short'), strtotime($product_info['sale_end_date'])));
I have also modified the English language file to make dates a more readable format.

Code: Select all

$_['date_format_short']     = 'F j, Y';
$_['date_format_long']      = 'l, F jS, Y';