X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Finding the current time and doing some math in the templates (https://forum.x-cart.com/showthread.php?t=28022)

MCM 01-14-2007 09:30 PM

Finding the current time and doing some math in the templates
 
The new products mod is a neat one (and will be neater when I get it to work ;)). What I'd really like to do, though, is add something to the title of each item to show that it's new. Given the date added field in the database, I'd like to use $Product.add_date as a variable in an equation that would take the current time, subtract the add time, and display *NEW* in the title if the difference was less than a certain amount of time (to be specified later). What I need to know is the following:

-how can I call the current time?
-how can I put together the math in the .tpl file? Is it as simple as $current_time - $Product.add_date < $specified_time in a logical statement?

Thanks!

Jeremy

inebriate 01-14-2007 11:29 PM

Re: Finding the current time and doing some math in the templates
 
Quote:

{if $smarty.now - $products[product].add_date lt $specified_time}
*NEW*
{/if}


...the above code is just an example

MCM 01-15-2007 07:52 PM

Re: Finding the current time and doing some math in the templates
 
Thanks! That's just what I was looking for!

Jeremy


All times are GMT -8. The time now is 04:39 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.