Answers for "php date - 2 days"

PHP
4

Get the number of days between two dates in PHP

$startDate = new DateTime("2019-10-27");
$endDate = new DateTime("2020-04-11");

$difference = $endDate->diff($startDate);
echo $difference->format("%a");
Posted by: Guest on January-14-2021
1

Add 2 days to the current date in PHP

<?php
  $result = date('d.m.Y', strtotime('+2 day', time()));

  echo $result;
?>
Posted by: Guest on April-27-2022
-1

get 2 days before date in php

date('Y/m/d',strtotime("-1 days"));

Or Use DateTime class like this-

$date = new DateTime();
echo $date->modify("-1 days")->format('Y-m-d');
Posted by: Guest on June-22-2021

Browse Popular Code Answers by Language