Format Special Date

Support for Template related issues
Post Reply
Oistacus
Posts: 133
Joined: Sat Oct 08, 2011 3:21 pm
Location: Matera ITALY

Format Special Date

Post by Oistacus » Fri Nov 25, 2011 12:37 pm

Hi Brent,
is there a method to set this date in european format ( dd mm yyyy )?
Immagine.JPG
Immagine.JPG (25.78 KiB) Viewed 13250 times
Ois

User avatar
Brent
Site Admin
Posts: 4459
Joined: Sat Dec 12, 2009 3:35 pm
Location: Canada eh

Re: Format Special Date

Post by Brent » Fri Nov 25, 2011 2:57 pm

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.

Oistacus
Posts: 133
Joined: Sat Oct 08, 2011 3:21 pm
Location: Matera ITALY

Re: Format Special Date

Post by Oistacus » Fri Nov 25, 2011 3:33 pm

Hi ,
I thinked this , but the language remain in english always

User avatar
Brent
Site Admin
Posts: 4459
Joined: Sat Dec 12, 2009 3:35 pm
Location: Canada eh

Re: Format Special Date

Post by Brent » Fri Nov 25, 2011 3:38 pm

Let me make some changes using the new date class.

Oistacus
Posts: 133
Joined: Sat Oct 08, 2011 3:21 pm
Location: Matera ITALY

Re: Format Special Date

Post by Oistacus » Fri Nov 25, 2011 3:45 pm

Meanwhile I made ​​the change .

User avatar
Brent
Site Admin
Posts: 4459
Joined: Sat Dec 12, 2009 3:35 pm
Location: Canada eh

Re: Format Special Date

Post by Brent » Fri Nov 25, 2011 5:59 pm

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.

User avatar
Brent
Site Admin
Posts: 4459
Joined: Sat Dec 12, 2009 3:35 pm
Location: Canada eh

Re: Format Special Date

Post by Brent » Sat Nov 26, 2011 6:14 am

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

Post Reply