Re: Re: Error in Adding the 1 week,Month,Year for a particular date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



public function fn_getDateByDayDiff($year, $month , $day, $numDays = 0,
$sign = '+')
    {
        if($sign == '+')
        {
            $arrDateByDiff["day"] = date('j', mktime(0, 0, 0, $month  ,
($day + $numDays), $year)) ;
            $arrDateByDiff["month"] = date('n', mktime(0, 0, 0, $month  ,
($day + $numDays), $year)) ;
            $arrDateByDiff["year"] = date('Y', mktime(0, 0, 0, $month  ,
($day + $numDays), $year)) ;
        }
        else
        {
            $arrDateByDiff["day"] = date('j', mktime(0, 0, 0, $month  ,
($day - $numDays), $year)) ;
            $arrDateByDiff["month"] = date('n', mktime(0, 0, 0, $month  ,
($day - $numDays), $year)) ;
            $arrDateByDiff["year"] = date('Y', mktime(0, 0, 0, $month  ,
($day - $numDays), $year)) ;
        }

        return $arrDateByDiff;
    }

$arrDate = fn_getDateByDayDiff(date("Y"), date("m") , date("d"),
$numberInDays,  '+');

echo date("d-m-Y H",
mktime(0,0,0,$arrDate['month'],$arrDate['day'],$arrDate['year']) );



On Wed, Feb 25, 2009 at 9:12 PM, Brian H <brianh781@xxxxxxxxx> wrote:

>   What a mess...
>
>
> On Wed, Feb 25, 2009 at 9:16 AM, Larry Helms <larr_helms@xxxxxxxxx<larr_helms%40yahoo.com>>
> wrote:
>
> >
> > No, we're not supplying you the solution here... go do your homework on
> > your own!
> >
> > Gads!
> >
> > --- In php-objects@xxxxxxxxxxxxxxx <php-objects%40yahoogroups.com><php-objects%
> 40yahoogroups.com>,
>
> > "malayappa2000" <malayappa@...> wrote:
> > >
> > > Hi all we have the fallowing requirement we are getting the today date
> > > using $currenttime=date("d-m-Y H"); fuction
> > > and split the date and time using $splitdatetime = explode(" ",
> > > $currenttime);
> > >
> > > and spilt the date as date month year using
> > > $splitdate = explode("-", $date);
> > >
> > > what the problem we are facing is when we want to add 7days, 1month,
> > > 1year to splitted date month year values
> > >
> > > we used the fallowing code for adda week
> > > $month = $splitdate[1];
> > > $month1=$month+1;
> > > $monthday =date("d-m-Y H", mktime($day,$month1,$year, $hour));
> > > echo "month is".$monthday ."<br>";
> > >
> > > please tell some solution
> > >
> > > fallowing is the total code
> > >
> > > ------------------------------
> > >
> > > <?php
> > >
> > >
> > > $currenttime=date("d-m-Y H");
> > > echo "current time is ".
> > > //Expire in hours
> > > $expirehour = 48;
> > >
> > >
> > > //Split Time & Date
> > > $splitdatetime = explode(" ", $currenttime);
> > > $date = $splitdatetime[0];
> > > $time = $splitdatetime[1];
> > >
> > > echo "dayte is".$date."<br>";
> > > echo "time is".$time."<br>";
> > >
> > > //Split Date
> > > $splitdate = explode("-", $date);
> > > $day = $splitdate[0];
> > > $month = $splitdate[1];
> > > $year = $splitdate[2];
> > > $day1=$day+7;
> > > $month1=$month+1;
> > > $year1=$year+1;
> > > echo "day is".$day1."<br>";
> > > echo "month is".$month1."<br>";
> > > echo "year is".$year1."<br>";
> > >
> > > //Split Time
> > > $splittime = explode(":", $time);
> > > $hour = $splittime[0];
> > > echo "hours are" .$hour;
> > >
> > > //When does the time expire ?
> > > //$weekday = date("d-m-Y H", mktime($hour,$month,$day+$week1,$year));
> > > $weekday =date("d-m-Y H", mktime($day1,$month,$year, $hour));
> > > //$weekday =date("d-m-Y H", mktime(25,03,2009, $hour));
> > > echo "weekday is".$weekday."<br>";
> > >
> > > $monthday =date("d-m-Y H", mktime($day,$month1,$year, $hour));
> > > echo "month is".$monthday ."<br>";
> > >
> > > $yearday = date("d-m-Y H", mktime($day,$month,$year1, $hour));
> > > echo "year is".$yearday ."<br>";
> > >
> > > echo "printing mktime<br>";
> > > //echo date("M-d-Y", mktime(0, 0, 0, 10+1, 32, 1997));
> > >
> > >
> > > ?>
> > >
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
>  
>


[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux