How to convert 2016-06-14 21:40:53 as yesterday, 2016-06-15 21:40:53 as today and 2016-06-16 21:40:53 as tomorrow in php
<?php
$yourDate = new DateTime('2016-06-16 21:40:53');
$yourDate->setTime(0, 0, 0);
$now = new DateTime();
$now->setTime(0, 0, 0);
$diff = $now->diff($yourDate);
$diffInDay = (int)$diff->format('%R%a');
if ($diffInDay == -1) {
echo 'Yesterday';
} else if ($diffInDay == 0) {
echo 'Today';
} else if ($diffInDay == 1) {
echo 'Tomorrow';
} // ... etc
Try this I think your looking for
$date = date('Y-m-d H:i:s');
$newdate = strtotime ( '-1 day' , strtotime ( $date ) ) ;
$newdate = date ( 'Y-m-d H:i:s' , $newdate );
//yesterday
echo $newdate;
$tommorow = strtotime ( '+1 day' , strtotime ( $date ) ) ;
$tommorow = date ( 'Y-m-d H:i:s' , $tommorow );
echo $tommorow //tommorrow
echo date('Y-m-d H:i:s') //today