|
Posted by Gil on 06/21/07 18:13
On Jun 21, 1:42 pm, Gil <gilbert.mil...@gmail.com> wrote:
> I'm trying to mimic the functionality of netdaysworked in excel. The
> code below works, except when the date starts during daylight savings
> time. what is the number of seconds in a day for a daylight savings
> day?
>
> thanks,
> gil
>
> for ($dayval = $startdate; $dayval <=$enddate; $dayval+=$oneday){
> if (date(I,$dayval)==0){
> echo("daylight savings time<br>");
> }
>
> if(date(w,$dayval)==0){
> $daysworked = $daysworked+0;
> }
> elseif(date(w,$dayval)==6){
> $daysworked = $daysworked+0;
> }
> else{
> $daysworked++;
> }
> echo("first day: ".$dayval." number of days ".($dayval/86400)."
> lastday : ".$lastday."day of week :".date(w,$dayval)."date: ".date("m-
> d-Y",$dayval)." days worked: ".$daysworked."<br><br>");
> }
I solved the problem...
$sm = date("m",$startdate);
$sd = date("d",$startdate);
$sy = date("Y",$startdate);
$em = date("m",$enddate);
$ed = date("d",$enddate);
$ey = date("Y",$enddate);
$stjd = gregoriantojd($sm,$sd,$sy);
$edjd = gregoriantojd($em,$ed,$ey);
echo ("julian start date: ".$stjd."<br>");
echo ("julian end date: ".$edjd."<br>");
echo ("days between :".($edjd-$stjd)."<br>");
for ($dayval = $stjd; $dayval <=$edjd; $dayval+=1){
if (jddayofweek($dayval)==0){
$daysworked = $daysworked+0;
}
elseif (jddayofweek($dayval)==6){
$daysworked = $daysworked+0;
}
else{
$daysworked++;
}
Navigation:
[Reply to this message]
|