|
Posted by Schraalhans Keukenmeester on 05/31/07 13:27
At Thu, 31 May 2007 06:02:30 -0700, damezumari let h(is|er) monkeys type:
> http://www.phpbuilder.net/columns/akent20000610.php3?page=5
>
[snip]
>
> switch ($type)
> {
> case 'hours':
> $hours = $add + $hours;
> break;
> case 'minutes':
> $minutes = $add + $minutes;
> break;
> case 'seconds':
> $seconds = $add + $seconds;
> break;
> case 'months':
> $months = $add + $months;
> break;
> case 'days':
> $days = $add + $days;
> break;
> case 'years':
> $years = $add + $years;
> break;
> }
> $timestamp = mktime($hours, $minutes, $seconds, $months, $days,
> $years);
> $newdatetime = date('Y-m-d H:i:s', $timestamp);
> return ($newdatetime);
> }
>
> 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?
>
$$type += $add;
But, why are you reinventing the strtotime function?
$dayaftertomorrow = date('D M j G:i:s T Y',strtotime('+2 days'));
HTH,
Sh.
--
Schraalhans Keukenmeester - schraalhans@the.spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]
"strcmp('apples','oranges') < 0"
Navigation:
[Reply to this message]
|