Change datetime to date and time using PHPExcel

Hi,

i am trying to convert datetime to date and time. I’ve been using PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY but it does not work.
Can anyone help me please?

This is what i’m getting
datetime

and this is my code

$numRow =1;
while( $data = sqlsrv_fetch_object($result)) {

$numRow = $numRow + 1;
    $date = $data->LogDate;

    $objPHPExcel->getActiveSheet()->setCellValue("A".$numRow,  $date); // suppose to be date
$objPHPExcel->getActiveSheet()->setCellValue("B".$numRow,  $date); // suppose to be time

//style to date
$objPHPExcel->getActiveSheet()
->getStyleByColumnAndRow(“A”.$numRow)
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY );

//style to time
$objPHPExcel->getActiveSheet()
->getStyleByColumnAndRow(“B”.$numRow)
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
}

Sponsor our Newsletter | Privacy Policy | Terms of Service