Re: Variable substitution to replace switch
- From: Rami Elomaa <rami.elomaa@xxxxxxxxx>
- Date: Thu, 31 May 2007 19:55:41 +0300
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@xxxxxxxxx
"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
.
- Follow-Ups:
- Re: Variable substitution to replace switch
- From: Rami Elomaa
- Re: Variable substitution to replace switch
- References:
- Variable substitution to replace switch
- From: damezumari
- Re: Variable substitution to replace switch
- From: Schraalhans Keukenmeester
- Re: Variable substitution to replace switch
- From: damezumari
- Variable substitution to replace switch
- Prev by Date: Re: Writing to Heredoc from Text Area Form
- Next by Date: Re: Collecting User Information
- Previous by thread: Re: Variable substitution to replace switch
- Next by thread: Re: Variable substitution to replace switch
- Index(es):
Relevant Pages
|