Tema: Por QUE?
Ver Mensaje Individual
  #20 (permalink)  
Antiguo 04/06/2007, 15:58
santuariosw
 
Fecha de Ingreso: diciembre-2006
Ubicación: Miami
Mensajes: 55
Antigüedad: 17 años, 4 meses
Puntos: 0
Solucion

Gracias a un colega de cubatravel en cuba y a todos ustedes se pudo resolver esto, todos ustedes tenian razon en lo que me decian pero cuando no mke daba error solo me calculaba el 1er registro bueno sin mas muela la sulucion es sacar esto fuera del loop
Código PHP:
<?php
// Set the default timezone to US/Eastern time:
date_default_timezone_set('US/Eastern');

// This function will count the number of business days between two dates

function count_business_days($a$b) {
    
// First, sort these.  We need to know which one comes first
    
if ($a $b) {
        
$first $a;
        
$second $b;
    } else {
        
$first $b;
        
$second $a;
    }

    
// Break these timestamps up into their constituent parts:
    
$f getdate($first);
    
$s getdate($second);

    
// Calculate the number of business days in the first week left.
    // Do this by subtracting the number of the day of the week from Friday
    
$f_days $f['wday'];
    
// If it was Saturday or Sunday you will get a -1 or 5 but we want 0
    
if (($f_days == 5) || ($f_days 0)) { $f_days 0; }

    
// Do the same for the second week except count to the beginning of
    // the week.  However, make sure that Saturday only counts as 5
    
$s_days = ($s['wday'] > 5) ? $s['wday'];

    
// Calculate the timestamp of midday, the Sunday after the first date:
    
$f_sunday mktime(1200$f['mon'],
                    
$f['mday'] + (($f['wday']) % 7), $f['year']);

    
// And the timestamp of midday, the Sunday before the second date:
    
$s_sunday mktime(1200$s['mon'],
                    
$s['mday'] - $s['wday'], $s['year']);

    
// Calculate the full weeks between these two dates by subtracting
    //  them, then dividing by the seconds in a week.  You need to round
    //  this afterwards to always ensure an even number.  Otherwise
    //  daylight savings time can offset the calculation.
    
$weeks round(($s_sunday $f_sunday) / (3600*24*7));

    
// Return the number of days by multiplying weeks by 5 and adding
    //  the extra days:
    
return ($weeks 5) + $f_days $s_days;
}
?>
y dentro del loop eso

Código PHP:
<?php
// Try a couple of examples:
$date1 strtotime($variable de fechainicial);
$date2 strtotime($variable de fechafinal);
// Calculate the business days between, They are: 31 & 8109
echo "<p>There are "count_business_days($date1$date2), " days.</p>";
?>
el problema que me daba aparte de no redeclarar la funcion era que yo estaba poniendo

Código PHP:

$date1 
date ("m/d/Y h:ja"strtotime($variable de fechainicial));
$date2 date ("m/d/Y h:ja"strtotime($variable de fechafinal);