In the past I have just been sticking dates in Excel as a string, which works, but I want to format them as a date so I cobbled this function together from looking on the internet and trying to work out how to do it. Unfortunately when I use my function the date keeps coming out as false.
myCellDate('C9','2015-05-05');
public function myCellDate($range,$text){
$this->obj->getActiveSheet()
->setCellValue($range, PHPExcel_Shared_Date::PHPToExcel( $text ));
$this->obj->getActiveSheet()
->getStyle($range)
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);;
}
I was hoping to get this to put the date in Excel as 2015/05/05 and then get the formatting to show something like 14 June 2017 format.
However all I get in Excel is FALSE. I think it might have something to do with date conversion, but I am not sure.