PHPBuilder - NextDay



RSS Twitter
Snippets Calendars Dates

NextDay

by: Riccardo Pasquini
|
January 8, 2001

Version: 1

Type: Function

Category: Calendars/Dates

License: GNU General Public License

Description: u have a date and want to know the next day i used it for loops.....



$aDaysXMonth=array(0,31,28,31,30,31,30,31,31,30,31,30,31);

function biSest($year)    //leap-year
{
         return (((0==$year%4 && 0!=$year%100) || 0==$year%400)?1:0);
}

function nextDate($dt)
{
        global $aDaysXMonth;

        //scompone la data in formato dd/mm/yyyy
        $g=substr($dt,0,2);     //day
        $m=substr($dt,3,2);     //month
        $y=substr($dt,6);       //year

        settype($g,"integer");
        settype($m,"integer");
        settype($y,"integer");

        $maxDelMese=$aDaysXMonth[$m];

        if(2==$m)
           $maxDelMese+=biSest($y);

        $g++;

        if($g>$maxDelMese)
        {
            $g=1;
            $m++;
            if($m>12)
            {
                $m=1;
                $y++;
            }
        }

        return (($g<10)?"0":"").$g."/".(($m<10)?"0":"").$m."/".$y;       //ricostruisce la data successiva - return the next day
}

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Riccardo Pasquini

Comment:



Comment:

(Maximum characters: 1200). You have characters left.