reading the exact time from excel using php

Topics: Developer Forum
Jul 24, 2014 at 6:43 AM
I made a php script that parses xls file. It works well but the only problem is that

when php read the cell it only reads 7/21/2014 0:43

also when i go to the xls and click the cell it shows the right format which is

7/21/2014 12:21:05 AM
why does xls hides it?

how can i convert that?
when i use $date_time = date('Y-m-d H:i:s', strtotime($date));
to format it took away the seconds it only returns 2014-07-21 00:43:00

please help me, is there a way i can convert it back to hh:mm:ss format (having the seconds).

this is my code, i just want to know if there is a way that php can get the right output because its reading in wrong format.
<?php
        
        /* PROCESS EXCEL PARSER */
        /* PARSE IF UPLOAD SUCCESSFUL */
        
        set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');

        include 'inc/phpexcel/PHPExcel/IOFactory.php';

        $inputFileName = 'file.xls';

        try{

                /**  Identify the type of $inputFileName  **/
                $inputFileType = PHPExcel_IOFactory::identify($inputFileName);

                /**  Create a new Reader of the type that has been identified  **/
                $objReader = PHPExcel_IOFactory::createReader($inputFileType);

                /**  Load $inputFileName to a PHPExcel Object  **/
                $objPHPExcel = $objReader->load($inputFileName);

        } catch(Exception $e) {
                
                die();
        }
                        
        $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);

        $columns = array(       'ID', 'Date/Time', 'File', 'Sender', 'Operator', 'Cost', 'Total', 'Message', 'Notification' );
        $indexes = array(       'ID' => '', 'Date/Time' => '', 'File' => '', 'Sender' => '', 'Operator' => '',
                                                'Cost' => '', 'Total' => '', 'Message' => '', 'Notification' => '');

        /* FIND AND SAVE INDICES */

        foreach( $sheetData[1] as $key => $val ){
                if( in_array( $val, $columns ) ){
                        $indexes[$val] = $key;
                }
        }
                                
        foreach($sheetData as $cell_key => $cell_val) {

                if( $ctr > 0 ) {
                
                        if( in_array( $cell_val[$indexes['ID']], array('101-100', '101-101', '101-102') )  ) {
        
                                $direction =  $cell_val[$indexes['ID']];
                                $date =  $cell_val[$indexes['Date/Time']];
                                $date_time = date('Y-m-d H:i:s', strtotime($date));
                                $duration =  $cell_val[$indexes['File']];
                                $dialed =  $cell_val[$indexes['Sender']];
                                $caller =  $cell_val[$indexes['Operator']];
                                $rate =  $cell_val[$indexes['Cost']];
                                $charge =  $cell_val[$indexes['Total']];
                                $custom =  $cell_val[$indexes['Message']];
                                $result =  $cell_val[$indexes['Notification']];
                                
                        }
                }
                $ctr++;
        }

        unlink($inputFileName);
?>
This is what the output i need:

2014-07-21 00:43:05
Thank you.