0
<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?

GYaN
  • 2,327
  • 4
  • 19
  • 39
Tomeikun
  • 309
  • 1
  • 2
  • 5

2 Answers2

1
<?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') ;
Wils
  • 1,178
  • 8
  • 24
0

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
Claudio Busatto
  • 721
  • 7
  • 17