0

The value of Cell C13 is: 01/02/2018 and i need to get same result on output but:

If using $d_calib = $spreadsheet->setActiveSheetIndex(2)->getCell( 'C13' )->getValue(); the result is: 42010

also if echo $d_calib = $spreadsheet->setActiveSheetIndex(2)->getStyle( 'C13' )->getNumberFormat()->setFormatCode('d/m/Y'); the result is: Object of class could not be converted to string if i do print_r to it the result is out of memory.

Any suggestions to solve this problem ?

Mina
  • 31
  • 7

2 Answers2

1

$spreadsheet->setActiveSheetIndex(2)->getStyle( 'C13' )->getNumberFormat()->setFormatCode('d/m/Y');

If you want to set a date format code in PHPSpreadsheet, then you need to set an Excel date format code, not a PHP date format code

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
0

used:

    $value = $worksheet->getCell('C13')->getValue();
    $date2 = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($value);
    echo $date2->format('d/m/Y');
Mina
  • 31
  • 7