Answers for "php date subtract 1 year"

PHP
3

minus 1 year php

$year = new DateTime(date('Y-m-d')); // gets current date
$interval = new DateInterval('P1Y');
$year->sub($interval); // subtract 1 year with $interval

// var_dump($year->format('Y')); or var_dump($year->format('Y-m-d'));
Posted by: Guest on October-22-2021
0

php date format minus 1 day

date('Y-m-d',(strtotime ( '-1 day' , strtotime ( $date) ) ));
Posted by: Guest on September-05-2021
0

subtract some days php

// First date of the month.
$monthFirstDate = date('Y-m-01', strtotime('today'));

// Last date of the month.
$monthLastDate = date('Y-m-t', strtotime('today'));

// Second last date of the month
$monthLastSecondDate = date('Y-m-d', strtotime('-2 day', strtotime('today')));
Posted by: Guest on September-07-2021

Browse Popular Code Answers by Language