Forums / Developer / timestamp manipulation

timestamp manipulation

Author Message

laurent le cadet

Friday 17 August 2007 10:37:57 am

Hi,

I need to work on timestamp to compare a date attribute with the current date to print out if an object can be considered as new or not.

My starting point :

{def $currentimestamp = cond( and(ne($view_parameters.month, ''), ne($view_parameters.day, ''), ne($view_parameters.year, '')), makedate($view_parameters.month, $view_parameters.day, $view_parameters.year), currentdate() )
     $objectimestamp = $node.object.data_map.date_marche.data_int}

What I want is to check if the $objectimestamp is older of 3 monthes than the $currentimestamp but I don't know how to work on $currentimestamp to retrieve him a 3 monthes "timestamp value" to make a new $customtimestamp.

Yhan it could be :

	{if gt($objectimestamp,$customtimestamp)}
	<div class="new">
		<img src={"images/new.gif"|ezdesign} height="11" width="48" title="New" alt="New" />
	</div>
	{/if}

Any hint?

Regards.

Laurent

Felix Laate

Saturday 18 August 2007 8:50:25 am

Hi Laurent,

just a thaught.

With 3 months, do you mean 3 x 30 days? In that case you would want to show all objects with a timestamp greater than the timestamp of currentdate() - 7776000 (90 days of seconds).

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

laurent le cadet

Monday 20 August 2007 12:02:16 am

Felix,

Excatly what I need. So it turns like this :

{def $currentimestamp = cond( and(ne($view_parameters.month, ''), ne($view_parameters.day, ''), ne($view_parameters.year, '')), makedate($view_parameters.month, $view_parameters.day, $view_parameters.year), currentdate() )
$objectimestamp = $node.object.data_map.date_marche.data_int}


{if gt($objectimestamp, sub($currentimestamp,7776000) )}
     <img src={"images/new.gif"|ezdesign} height="11" width="48" title="New" alt="New" />
{/if}

Thanks a lot.

Laurent