<p>Closing on <span>{{ $event->endDate->format('d/m/Y') }}</span></p>
Now my current result is Closing on 13/1/2017.
The result I request for is Closing on 12/1/2017.
how to -1 day from it?
<p>Closing on <span>{{ $event->endDate->format('d/m/Y') }}</span></p>
Now my current result is Closing on 13/1/2017.
The result I request for is Closing on 12/1/2017.
how to -1 day from it?
<?php
echo date('d-m-Y',strtotime('-1 day', strtotime(date('13-01-2017'))));
Use strtotime, it support this -1day notation.
or datetime oop way
echo (new DateTime('13-01-2017'))->sub(new DateInterval('P1D'))->format('d-m-Y') ;
In your case,
echo (new DateTime($event->endDate->format('d-m-Y')))->sub(new DateInterval('P1D'))->format('d/m/Y') ;
Have a look in the strtotime function.
// Initial date
echo $event->endDate->format('d/m/Y'); // 13/1/2017
// Modify the date
$oneDayAgo = date('Y-m-d H:i:s',
strtotime('-1 day', strtotime($event->endDate->format('d/m/Y'))));
echo $oneDayAgo; // 12/1/2017