Q:

Date is not converting in the desired format

i am using PHPExcel to import a data to the database.  All is going well but i am having a problem in data column.  I have two types if excel sheet.  One having date column as a general format it did not give any error.  
But in the second excel sheet there there was error after some debugging i came to know that in excel there is formatting of the cell in the date format.  
This is the code which i try to run 
$formatted_date = $this->worksheet->getCell($this->date .  $row)->getFormattedValue();
        $dat = date_format($formatted_date, "Y/m/d");

i was converting it into date and from this i got this error
date_format() expects parameter 1 to be DateTimeInterface, string given

then i try to make it a date format object from this by creating a date
$formatted_date = date_create($this->worksheet->getCell($this->date .  $row)->getFormattedValue());
        $dat = date_format($formatted_date, "Y/m/d");

but then it is giving the error of boolean 
date_format() expects parameter 1 to be DateTimeInterface, boolean given

any help would be much appreciated if this is the phpexcel pr the php problem.? 

A:

If the date is a format that DateTime cannot recognise, then you should probably use date_create_from_format() instead, and tell it what format you are using. 
Alternatively, rather than using 
$formatted_date = $this->worksheet->getCell($this->date .  $row)->getFormattedValue();

use 
$dateTimeObject = PHPExcel_Shared_Date::ExcelToPHPObject(
    $this->worksheet->getCell($this->date .  $row)->getValue()
);

and you can then use all the appropriate PHP DateTime object methods such as format() to do whatever you want with the value.