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

Hans design5 at softflow.co.uk
Wed Feb 27 11:51:56 CST 2008

Wednesday, February 27, 2008, 5:29:02 PM, Patrick R. Michaud wrote:

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

> One should note that both this and the udays approach have a
> potential problem if the range of dates span changes in daylight
> savings time.  In this case the difference will not be an even
> multiple of 86400, and using floor() will provide an incorrect
> value.

The expression above will indeed produce a fraction in this case,
but using

    {(sub (udays '{$:Date}') (udays now) )}

will still result in an integer number of days. Each udays expression
produces an integer, never mind what time you include in the date.
So I think it might be quite useful, as it is also simpler.


More information about the pmwiki-users mailing list