PhpToExcel date transformation problem

Topics: Developer Forum, User Forum
Aug 22, 2011 at 11:52 AM

Hi,

 

if got this code:

date_default_timezone_set('Europe/London');
$date = strtotime('2011-08-01'); $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B1',PHPExcel_Shared_Date::PHPToExcel($date)); $objPHPExcel->getActiveSheet()->getStyle('B1')->getNumberFormat()->setFormatCode('dd.mm.yyy 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 12: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 10:27 AM
I had the same problem with the library.

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

e.g.
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');