Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/01/2011, 09:59
brepon
 
Fecha de Ingreso: noviembre-2010
Mensajes: 21
Antigüedad: 13 años, 4 meses
Puntos: 0
resta dias a fecha

Hola,
He encontrado este código, y me pregunto, también puede servir para restar
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ñ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ño)=split("-",$fecha);
             
        
$nueva mktime(0,0,0$mes,$dia,$año) + $ndias 24 60 60;
        
$nuevafecha=date("d-m-Y",$nueva);
            
 
      return (
$nuevafecha);  
  }
echo 
'<head>
            
 
              <title>'
.$_SERVER[PHP_SELF].'</title>
            
 
      </head>
       <html>
       <body>'
;
       
$f1="06/02/2011";
$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>'
;
?>