Php subtract days from date

7 Nov

Here are one examples you can use to subtract date in php.

Sometime we have to calculate the expiry date in our mysql table. to find out that a particular date has been expired our not.

Below Examples Explaining how we can subtract days from a dates.

$d = date('d');
$d = $d - 1; //subtracting one days from current day
$m = date('m');
$Y = date('Y');
$H = date('H');
$i = date('i');
$s = date('s');
$back_date = date("Y-m-d H:i:s", mktime($H, $i, $s, $m, $d, $Y));

You can add days in $d variable to get future date. thus you can add month year or hours and minutes anything to calculation old or new date.

Leave a Reply

Your email address will not be published. Required fields are marked *

3 − three =