php - PHPExcel gets wrong timezone even after setting date_default_timezone_set -


i'm using http://phpexcel.codeplex.com in 1 of project, , have come issue. want write time() value inside cell, doing :

function writetimeline($objactivesheet, &$linenumber, $timestart, $timeend, $duration, $category, $client, $date, $comment) {     $objactivesheet->setcellvalue('a'.$linenumber, phpexcel_shared_date::phptoexcel( $timestart ));     $objactivesheet->getstyle('a'.$linenumber)->getnumberformat()->setformatcode(phpexcel_style_numberformat::format_date_time4); } 

the $objactivesheet refers $objphpexcel->getactivesheet()

and result in excel is:

20:27:39

when in real on computer i'm testing it's 16:27:39

so it's issue timezone (i'm living in eastern america -4). however, i'm including phpexcel files after setting default timezone with

date_default_timezone_set('america/new_york'); 

and echo of time() see correct hour (16:27:39).

is bug of phpexcel or doing wrong here?

thanks help.

instead of changing phpexcel lib, better add time difference:

$timestart + date('z', $timestart)

for example that:

date_default_timezone_set('america/new_york'); function writetimeline($objactivesheet, &$linenumber, $timestart, $timeend, $duration, $category, $client, $date, $comment) {     $objactivesheet->setcellvalue('a'.$linenumber, phpexcel_shared_date::phptoexcel( $timestart + date('z', $timestart) ));     $objactivesheet->getstyle('a'.$linenumber)->getnumberformat()->setformatcode(phpexcel_style_numberformat::format_date_time4); }


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -