Fahdi’s Personal Blog

Here I share my web ideas

A PHP function for date aritmetic simple and easy way to do date arithmetic

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
January10
function adddate($timesent,$daystoincrement=0,$monthstoincrement=0,$yearstoincrement=0){///echo "Original date is ".date("M-d-Y",$timesent);/*

$daystoincrement=32;

$yearstoincrement=-1;

$monthstoincrement=2;*/

$timesentnew=date("M-d-Y", mktime(0, 0, 0,date('m',$timesent)+$monthstoincrement,date('d',$timesent)+$daystoincrement,date('Y',$timesent)+$yearstoincrement));

//echo "Date after adding ".$daystoincrement." days, ".$yearstoincrement." years and ".$monthstoincrement."months equals " .$timesentnew."";

return $timesentnew;

}

echo adddate(time(),0,8,0);
Share and Enjoy:
  • Digg
  • Facebook
  • LinkedIn
  • NewsVine
  • Technorati
  • Sphinn
  • del.icio.us
  • Mixx
  • Google
  • StumbleUpon
  • Live
  • Print this article!
  • feedmelinks
  • E-mail this story to a friend!
  • Reddit

Email will not be published

Website example

Your Comment: