3 error_reporting(E_ALL);
6 date_default_timezone_set('Europe/London');
12 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
14 <title>PHPExcel Calculation Examples</title>
20 <h2>Converts a time in the form of text to a serial number.</h2>
24 set_include_path(get_include_path() . PATH_SEPARATOR . '../../../../Classes/');
26 /** Include PHPExcel */
27 include 'PHPExcel.php';
30 // Create new PHPExcel object
31 $objPHPExcel = new PHPExcel();
32 $worksheet = $objPHPExcel->getActiveSheet();
35 $testDates = array( '3:15', '13:15', '15:15:15', '3:15 AM', '3:15 PM', '5PM', '9:15AM', '13:15AM'
37 $testDateCount = count($testDates);
39 for($row = 1; $row <= $testDateCount; ++$row) {
40 $worksheet->setCellValue('A'.$row, $testDates[$row-1]);
41 $worksheet->setCellValue('B'.$row, '=TIMEVALUE(A'.$row.')');
42 $worksheet->setCellValue('C'.$row, '=B'.$row);
45 $worksheet->getStyle('C1:C'.$testDateCount)
47 ->setFormatCode('hh:mm:ss');
55 <table border="1" cellspacing="0">
59 <th>Excel TimeStamp</th>
60 <th>Formatted TimeStamp</th>
63 for ($row = 1; $row <= $testDateCount; ++$row) {
65 echo '<td>' , $worksheet->getCell('A'.$row)->getFormattedValue() , '</td>';
66 echo '<td>' , $worksheet->getCell('B'.$row)->getValue() , '</td>';
67 echo '<td>' , $worksheet->getCell('B'.$row)->getFormattedValue() , '</td>';
68 echo '<td>' , $worksheet->getCell('C'.$row)->getFormattedValue() , '</td>';