php - PHPExcel Is there any way to validate input date in dd-mm-yyyy format? -


i have following code reading data .xls file.

$inputfiletype = phpexcel_iofactory::identify($inputfilename);  $objreader = phpexcel_iofactory::createreader($inputfiletype);  $objreader->setreaddataonly(false);    $objphpexcel = $objreader->load($inputfilename);  $objworksheet = $objphpexcel->setactivesheetindex(0);  $highestrow = $objworksheet->gethighestrow();  $highestcolumn = $objworksheet->gethighestcolumn();  $highestcolumnindex = phpexcel_cell::columnindexfromstring($highestcolumn);    $chunksize=_chunksize_;  $endrow=$chunksize;  $count=ceil($highestrow/$chunksize);    ($row=1;$row<=$endrow;$row++)          {              if($row>$highestrow){                  break;              }              ($col=0;$col<$highestcolumnindex;$col++)              {                  $cellobj=$objworksheet->getcellbycolumnandrow($col, $row);                  $value=$cellobj->getvalue();                  if(phpexcel_shared_date::isdatetime($cellobj)) { //to check date                      $value=$cellobj->getformattedvalue();                                        }              }          }

here returns date in 'mm-dd-yyyy' format when in date provided in format. need validate date should in 'dd-mm-yyyy'.

rather use

if(phpexcel_shared_date::isdatetime($cellobj)) { //to check date     $value=$cellobj->getformattedvalue(); } 

to verify if cell contains date, , convert string formatted using cells format mask, use

if(phpexcel_shared_date::isdatetime($cellobj)) { //to check date     $datetimeobj = phpexcel_shared_date::exceltophpobject($cellobj->getvalue()); } 

and can use datetime object's format() method format want


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -