Created
June 30, 2019 12:03
-
-
Save jhonsore/b715b8823e27332bce74c86e9e54b26d to your computer and use it in GitHub Desktop.
Add months, days, years to PHP date()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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