[pmwiki-users] calculation with time

noskule noskule at gmx.net
Thu Jun 5 05:03:53 CDT 2008

Peter & Melodye Bowers schrieb:
> If you are talking about in the underlying PHP:
>>     if "current time" < "current time"-"two weeks"
> If (time() < (time() - (2 * 7 * 24 * 60 * 60)))
>>     if "current time" < "current time"-"two hours"
> If (time() < (time() - (2 * 60 * 60)))
>>     if "current time" < "current time"-"two minutes
> If (time() < (time() - (2 * 60)))
> Obviously none of these will ever be true since you've specified "current
> time" as both sides of the comparison, but I'm assuming that the left side
> of the comparison will be some value that you will store in a variable or
> something.
yes your right. I should wrote
$timelastaction < $currenttime - "two weeks"

the thing what I'm looking for is actually the format in which I should 
store time values. I save ptv's for timelastaction, timecreated, 
lastedited. I would like to use this values for various time 
calculations, eg if a blogpost is older than xx days.

Currently I save this in unix time so I can do math operations very 
easily. Unfortunality it isn't a proper format to write time in a form 

So I thought that there may be a way to do calculation with a standard 
data/time format to. But what I read this seams various problems if the 
year change and such.

I have a markup that translates unixtime to

$MarkupExpr['timefmt'] = 'ShowTimeFmt($args[0])';
function ShowTimeFmt($unixtime) {
    $timefmt = strftime($GLOBALS['TimeFmt'],$unixtime);
    return $timefmt;

Does you know of a function that can translate date/time back to unixtime?

grz nos

> Seems like strftime('%u') would give similar capabilities but maybe not on
> all platforms (this is available via MarkupExpression if you are doing this
> within markup instead of at the PHP level)?  
> -Peter

More information about the pmwiki-users mailing list