PhpToExcel date transformation problem

Topics: Developer Forum, User Forum
Aug 22, 2011 at 12:52 PM



if got this code:

$date = strtotime('2011-08-01'); $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B1',PHPExcel_Shared_Date::PHPToExcel($date)); $objPHPExcel->getActiveSheet()->getStyle('B1')->getNumberFormat()->setFormatCode(' hh:mm');
and the excel output is 31.07.2011 23:00, i cant understand way ... PHP converts the string correctly but the problem comes from within  PhpToExcel, did someone else had this problem? and is there a solution?

Aug 22, 2011 at 1:10 PM

i found the problem, the PHPToExcel functions has date_default_timezone_set set to UTC, can it be changed?

Oct 16, 2014 at 11:27 AM
I had the same problem with the library.

My solution was the change the source to set the timezone.

In PHPExcel\Calculation\DateTime.php and PHPExcel\Shared\Date.php

I amended any date_default_timezone_set('UTC'); to be date_default_timezone_set('Europe/London');