PHP

ADD & SUBTRACT DAYS WEEKS MONTHS FROM A DATE

(quick examples)

ORIGINAL TIME $dt = new DateTime("2019-08-07");

DATE TIME OBJECT

01

ADD DATE $dt->modify("+4 days"); echo $dt->format("d M Y");

SUBTRACT DATE $dt->modify("-2 weeks"); echo $dt->format("d M Y");

ORIGINAL TIME $date = "2019-08-07";

STRING TO TIME

02

ADD DATE echo date("d M Y", strtotime($date."+2 days")); 

SUBTRACT DATE echo date("d M Y", strtotime($date."-3 weeks"));

UNIX TIMESTAMP $unix = strtotime("2019-08-07");

UNIX TIMESTAMP

03

ADD DATE echo date("d M Y", $unix + (4*$day));

SUBTRACT DATE echo date("d M Y", $unix - (7*$day));