Add months, days, years to PHP date()


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $date = date("Y-m-d");
  2. $date = strtotime(date("Y-m-d", strtotime($date)) . " +12 month");
  3. $date = date("Y-m-d",$date);
  4. echo $date;
  5.  
  6. Other examples
  7. $date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
  8. $date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
  9. $date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
  10. $date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
  11. $date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.