Note Submitter: Oliver Thies oliver_thies at hotmail dot com
Reason: non-english
----
function dateAdd($Data,$qtd)
{
$dia = substr($Data,0,2);
$mes = substr($Data,3,2);
$ano = substr($Data,6,4);
//tratando o mes
if ($mes < 10) { $mes = str_replace(0,'',$mes);}
//Array para pegar o ultimo dia de cada mes.
$ultimodia = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
30, 31);
$novodia = $dia + $qtd;
//echo $novodia;
//break;
for(;;)
{
if ($novodia > $ultimodia[$mes -1])
{
$novodia = ($novodia - $ultimodia[$mes -1]);
$mes = $mes + 1;
if ($mes > 12)
{
$mes = 1;
$ano = $ano + 1;
}
} else {
break;
}
}
if (strlen($mes)==1)
{
$mes = "0" . $mes;
}
if (strlen($novodia)==1)
{
$novodia = "0" . $novodia;
}
return $novodia . "/" . $mes . "/" .
$ano;
}
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|