DATE

Returns the serial number of a particular date.

getActiveSheet(); // Add some data $testDates = array( array(2012,3,26), array(2012,2,29), array(2012,4,1), array(2012,12,25), array(2012,10,31), array(2012,11,5), array(2012,1,1), array(2012,3,17), array(2011,2,29), array(7,5,3), array(2012,13,1), array(2012,11,45), array(2012,0,0), array(2012,1,0), array(2012,0,1), array(2012,-2,2), array(2012,2,-2), array(2012,-2,-2), ); $testDateCount = count($testDates); $worksheet->fromArray($testDates,NULL,'A1',true); for ($row = 1; $row <= $testDateCount; ++$row) { $worksheet->setCellValue('D'.$row, '=DATE(A'.$row.',B'.$row.',C'.$row.')'); $worksheet->setCellValue('E'.$row, '=D'.$row); } $worksheet->getStyle('E1:E'.$testDateCount) ->getNumberFormat() ->setFormatCode('yyyy-mmm-dd'); echo '
'; // Test the formulae ?> '; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } ?>
Date Value Formula Excel DateStamp Formatted DateStamp
Year Month Day
' , $worksheet->getCell('A'.$row)->getFormattedValue() , '' , $worksheet->getCell('B'.$row)->getFormattedValue() , '' , $worksheet->getCell('C'.$row)->getFormattedValue() , '' , $worksheet->getCell('D'.$row)->getValue() , '' , $worksheet->getCell('D'.$row)->getFormattedValue() , '' , $worksheet->getCell('E'.$row)->getFormattedValue() , '