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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 03:32:51
Script start
Timing: Jan 19 2025 03:32:51
Module start 'layout'
Timing: Jan 19 2025 03:32:51
Module start 'content'
Timing: Jan 19 2025 03:32:53
Module end 'content'
Timing: Jan 19 2025 03:32:53
Script end

Main resources:

Total runtime1.6704 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.1484152.6250
Module start 'layout' 0.00540.0048 741.773439.4297
Module start 'content' 0.01021.6589 781.2031540.3672
Module end 'content' 1.66900.0014 1,321.570312.5000
Script end 1.6704  1,334.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2140160.0002
Check MTime0.00160.0971160.0001
Mysql Total
Database connection0.00070.041510.0007
Mysqli_queries1.595195.4939570.0280
Looping result0.00170.1003550.0000
Template Total1.617096.820.8085
Template load0.00570.338920.0028
Template processing1.611396.463020.8057
Template load and register function0.00010.007310.0001
states
state_id_array0.00270.160510.0027
state_identifier_array0.00230.137020.0011
Override
Cache load0.00490.2927270.0002
Sytem overhead
Fetch class attribute can translate value0.00090.055120.0005
Fetch class attribute name0.01440.865050.0029
XML
Image XML parsing0.00120.072320.0006
class_abstraction
Instantiating content class attribute0.00000.001060.0000
General
dbfile0.00110.0666220.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs