PHP

HOW TO ADD SUBTRACT DAYS WEEKS MONTHS FROM A DATE

ORIGINAL TIME $dt = new DateTime("2019-08-14");   ADD DATE $dt->modify("+4 days"); echo $dt->format("d M Y");   SUBTRACT DATE $dt->modify("-2 weeks"); echo $dt->format("d M Y");

DATE TIME OBJECT

01

ORIGINAL TIME $date = "2019-08-14";   ADD DATE echo date("d M Y", strtotime($date."+2 days"));   SUBTRACT DATE echo date("d M Y", strtotime($date."-3 weeks"));

STRING TO TIME

02

UNIX TIMESTAMP $unix = strtotime("2019-08-14"); 1 DAY = 86400 SECS $day = 86400;   ADD DATE echo date("d M Y", $unix + (4*$day));   SUBTRACT DATE echo date("d M Y", $unix - (7*$day));

UNIX TIMESTAMP

03