Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/06/2007, 03:50
Avatar de kaninox
kaninox
 
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 8 meses
Puntos: 49
Re: sobre fechas, como sumar días.

Código PHP:
<?php
function suma_fechas($fecha,$ndias)
{

if (
preg_match("/[0-9]{1,2}\/[0-9]{1,2}\/([0-9][0-9]){1,2}/",$fecha))
            

              list(
$dia,$mes,$a&#241;o)=split("/", $fecha);
            

      
if (preg_match("/[0-9]{1,2}-[0-9]{1,2}-([0-9][0-9]){1,2}/",$fecha))
            

              list(
$dia,$mes,$a&#241;o)=split("-",$fecha);
        
$nueva mktime(0,0,0$mes,$dia,$a&#241;o) + $ndias * 24 * 60 * 60;
        
$nuevafecha=date("d-m-Y",$nueva);
            

      return (
$nuevafecha);  
            

}
echo 
'<head>
            

              <title>'
.$_SERVER[PHP_SELF].'</title>
            

      </head>
            

      <html>
            

      <body>'
;
$f1="30/01/1993";
            

$f2="30-01-1992";
$f11=suma_fechas($f125);
            

      echo 
"$f1 más 25 es  $f11<br>";
$f11=suma_fechas($f1, -40);
            

      echo 
"$f1 menos 40 es  $f11<br>";
$f21=suma_fechas($f2365);
            

      echo 
"$f2 más 365 es  $f21<br>";
$f21=suma_fechas($f2, -365);
            

      echo 
"$f2 menos 365 es  $f21<br>";
            

echo 
"<a href=$_SERVER[PHP_SELF]>Recargar la Página</a>";
echo 
'</body>
            

      </html>'
;
?>

el credito no es mio aqui la fuente ;)
http://dns.bdat.net/trucos/faqphp-v1/x385.html
__________________
Gokuh Salvo al mundo. PUNTO!!!!