|
Posted by Rami Elomaa on 05/31/07 16:55
damezumari kirjoitti:
> Thanks!
>
> strtotime()= it is!
>
> It would still be good to get my question answered:
>
> "It works OK, but I would like to replace the switch statement with
> one
> statement a la:
>
> &$type = &$type + $add;
>
> Can that be done in php?"
If they are unix timestamps and seconds yes. If not, you need to convert
them into such first. This is what strtotime does, and then using date
again reverses it.
You can do this:
$time0 = time(); // get a unix timestamp
$interval = 60*60*24; // one day in seconds.
$time0 += $interval; // add an interval to timestamp
echo date('Y-m-d H:i:s', $time0); // tomorrow
But this is good just for timestamps. Just remeber, working with
timestamps is dreadful when it comes to daylight saving, leap years and
other temporal oddities.
--
Rami.Elomaa@gmail.com
"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Navigation:
[Reply to this message]
|