Reply to Re: Variable substitution to replace switch

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация