Any variable to denote that new product for 14 days

in the product display area is there any way so that i can display its a new product for 14 days?
it can be a star or text “NEW” inside the product box

in details.tpl and product.tpl


		[{if ((time() - strtotime ($product->oxarticles__oxinsert->value)) / 60 / 60 / 24) < X }]<img src="[{$oViewConf->getImageUrl()}]newItem.gif">[{/if}]


Displays a little icon “newitem.gif” for a certain time period (X=14).

Regards
Gregor

Have anyone tested? Product is new, but the icon is not there to see.

tested also but cant get correct ouptut … maybe it’s because of sql-timestamp, not sure and didn’t checked further … smarty-plugin below works fine :slight_smile: !!

Input

  • date1 = “mm/dd/yyyy” or “yyyy/mm/dd” or “yyyy-mm-dd”
  • date2 = “mm/dd/yyyy” or “yyyy/mm/dd” or “yyyy-mm-dd” or $smarty.now
  • assign = name of variable to assign difference to
  • interval = “days” (default), “weeks”, “years”

Examples

  • {date_diff date1=“5/12/2003” date2=$smarty.now interval=“weeks”}
  • {date_diff date1=“5/12/2003” date2=“5/10/2008” assign=“diff”}{$diff}

<?php
/*

  • Smarty plugin

  • Type: function
  • Name: date_diff
  • Version: 2.0
  • Date: June 22, 2008
  • Author: Matt DeKok
  • Purpose: factor difference between two dates in days, weeks,
  •      or years
    
  • Input: date1 = “mm/dd/yyyy” or “yyyy/mm/dd” or “yyyy-mm-dd”
  •    date2 = "mm/dd/yyyy" or "yyyy/mm/dd" or "yyyy-mm-dd" or $smarty.now
    
  •    assign = name of variable to assign difference to
    
  •    interval = "days" (default), "weeks", "years"
    
  • Examples: {date_diff date1=“5/12/2003” date2=$smarty.now interval=“weeks”}
  •       {date_diff date1="5/12/2003" date2="5/10/2008" assign="diff"}{$diff}
    

*/
function smarty_function_date_diff($params, &$smarty) {
$date1 = mktime(0,0,0,1,1,2000);
$date2 = mktime(0,0,0,date(“m”),date(“d”),date(“Y”));
$assign = null;
$interval = “days”;

extract($params);

$i = 1/60/60/24;
if($interval == “weeks”) {
$i = $i/7;
} elseif($interval == “years”) {
$i = $i/365.25;
}

$date1 = ((is_string($date1))?strtotime($date1):$date1);
$date2 = ((is_string($date2))?strtotime($date2):$date2);

if($assign != null) {
$smarty->assign($assign,floor(($date2 - $date1)$i));
} else {
return floor(($date2 - $date1)
$i);
}
}
?>