Posted By

joeymarchy on 01/06/09


Tagged

date


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

fackz
kazey


Add months, days, years to PHP date()


 / Published in: PHP
 

  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  

You need to login to post a comment.