[pmwiki-users] How to: calculate how many days left

Patrick R. Michaud pmichaud at pobox.com
Wed Feb 27 10:20:14 CST 2008


On Wed, Feb 27, 2008 at 10:41:34AM +0000, imoc wrote:
> Sorry for delaying to this thread. Being busy.
> 
> I'm a little confused about the solution, so, may I reorganize it as follow 
> and please correct me if I write something wrong:
> 
> 1) Installing http://www.pmwiki.org/wiki/Cookbook/MarkupExprPlus recipe
> 
> 2) Adding some codes in config.php
> 
> # unix time, seconds since 1970-01-01
> $MarkupExpr['utime'] = 'MxUTime($args[0])';
> function MxUTime($arg) {
>         $udate = date('U', strtotime($arg));
>         if ($arg=='now') $udate = time();
>         return $udate;
> 
> }

You really don't need this utime function, since PmWiki's 
built-in ftime function can already do it.

    {(ftime %s now)}
    {(ftime %s {$:Date})}

However, if the point is to have a short version of 'ftime'
that doesn't require the %s argument, that's okay.  :-)

> 3) Using " {(sub (udays {$:Date}) (udays now) )} " in wiki pages to 
>    get number of how many days left.

Simpler might be

    {(div (sub (ftime %s {$:Date}) (ftime %s)) 86400)}

Pm




More information about the pmwiki-users mailing list