Skip to content

Instantly share code, notes, and snippets.

@jhonsore
Created June 30, 2019 12:03
Show Gist options
  • Select an option

  • Save jhonsore/b715b8823e27332bce74c86e9e54b26d to your computer and use it in GitHub Desktop.

Select an option

Save jhonsore/b715b8823e27332bce74c86e9e54b26d to your computer and use it in GitHub Desktop.
Add months, days, years to PHP date()
//found on https://snipplr.com/view.php?codeview&id=10958
$date = date("Y-m-d");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +12 month");
$date = date("Y-m-d",$date);
echo $date;
Other examples
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment