Link | vz_elapsedtime |
Author | Pier Kuipers |
Category | Date |
Version | 8.5.x |
License | Public Domain |
Posted | 25 Jul 2008 |
Updated | 25 Jul 2008 |
More by this author... |
Given a date and optional time, this tag will return a string displaying its offset compared to the current time in the format "[n] [units] ago".
[vz_elapsedtime(field('creation_date'))] -> '23 minutes ago' -> '5 days ago' -> '1 month ago' If the tag would return "1 day ago", it changes the output to -> 'yesterday'
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
if(!lasso_tagexists('vz_elapsedtime')); define_tag('elapsedtime', -description='given a date and optional time, this tag will return a string displaying its offset compared to the current time in the format "[n] [units] ago".', -namespace='vz_', -required='datetime', -Priority='Replace'); local('timenow'=date); local('output'=string); local('timespans'=(array('year', 'month', 'week', 'day', 'hour', 'minute', 'second'))); iterate(#timespans, local('tmp')); local('diff'=(date_difference(#timenow, #datetime, #tmp))); if(#diff > 0); if((#tmp=='day')&&(#diff==1)); #output = 'yesterday'; else; #output = #diff+' '#tmp+(#diff>1?'s')+' ago'; /if; loop_abort; /if; /iterate; return(@#output); /define_tag; /if;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft