Issue
set format datetime with php and output excel
date_default_timezone_set('Asia/Bangkok');
$objPHPExcel->getActiveSheet()->SetCellValue('S1', 'Show DateTime');
$dateValue = PHPExcel_Shared_Date::PHPToExcel( strtotime('23-Apr-1989 17:05:50') );
$objPHPExcel->getActiveSheet()
->setCellValue('S2', $dateValue);
$objPHPExcel->getActiveSheet()
->getStyle('S2')
->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH);
How can show data on Excel 23/04/1989 17:05:50 and excel type Date
Solution
You currently use the predefined constant PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH
for your number format.
If you replace that by your desired format, everything should be ok: 'dd/mm/yyyy hh:mm:ss'
Also see the documentation for setFormatCode()
: http://apigen.juzna.cz/doc/ouardisoft/PHPExcel/class-PHPExcel_Style_NumberFormat.html#_setFormatCode
Answered By - Leviathan Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.