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

Hans design5 at softflow.co.uk
Wed Feb 27 10:51:42 CST 2008

Wednesday, February 27, 2008, 4:20:14 PM, Patrick R. Michaud wrote:

> 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.  :-)

I only realised later that ftime can output a unix timestamp with %s.
Curiously the strftime documentation on php.net says nothing about %s.

>> 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)}

 (ftime %s) is the unix time value for
Now, and not previous midnight, so the div above will have a fraction
The udays expression rounds down the division results, to arrive
at an integer number of days.


More information about the pmwiki-users mailing list