date

8 minutes read
This post is about How to add and subtract dates from one another. For example, this simple code can calculate what the date will be 5 weeks before or after from any specific date like: 2016-01-06 (yyyy-mm-dd). Subtracting days from a date The following example will subtract 2 days from 2016-01-06. $Date = "2016-01-06"; $sub_newdate = date('Y-m-d', strtotime($Date. ' - 2 day'));   Adding days into a date $add_newdate = date('Y-m-d', strtot...