Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php date minus x days

<?php
//New DateTime object representing current date.
$currentDate = new DateTime();
 
 
//Use the subtract function to subtract a DateInterval
$yesterdayTime = $currentDate->sub(new DateInterval('P1D'));
 
//Get yesterday date
$yesterday = $yesterdayTime->format('Y-m-d');
 
//Print yesterday date.
echo $yesterday;
?>
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #php #date #days
ADD COMMENT
Topic
Name
2+1 =