Warning: date_format() expects parameter 1 to be DateTime
You need to pass DateTime object to this func. See manual: php
string date_format ( DateTime $object , string $format )
You can try using:
date_format (new DateTime($time), 'd-m-Y');
Or you can also use:
$date = date_create('2000-01-01');
echo date_format($date, 'Y-m-d H:i:s');
Best way is use DateTime object to convert your date.
$myDateTime = DateTime::createFromFormat('Y-m-d', $weddingdate);
$formattedweddingdate = $myDateTime->format('d-m-Y');
Note: It will support for PHP 5 >= 5.3.0 only.
Why don't you try it like this:
$Weddingdate = new DateTime($row2['weddingdate']);
$formattedweddingdate = date_format($Weddingdate, 'd-m-Y');
Or you can also just do it like :
$Weddingdate = new DateTime($row2['weddingdate']);
echo $Weddingdate->format('d-m-Y');