Good day evening my goal here is when the excel has an empty date it will display in the data table an empty output, but it displays 01/01/1970 after I import excel empty data i had use strtotime format empty data in my excell Display in my datable
Here is my code below on displaying in the datable
<thead>
<tr>
<th class="text-center align-middle">Action</th>
<th class="text-center align-middle ">Last Name</th>
<th class="text-center align-middle ">First Name</th>
<th class="text-center align-middle ">Middle Name</th>
<th class="text-center align-middle ">Zone</th>
<th class="text-center align-middle ">Birth Day</th>
<th class="text-center align-middle ">Age</th>
<th class="text-center align-middle">Service Give</th>
<th class="text-center align-middle ">LMP</th>
<th class="text-center align-middle ">EDC</th>
<th class="text-center align-middle ">GPA</th>
<th class="text-center align-middle ">REMARKS</th>
<th class="text-center align-middle ">Teenage Pregnancy</th>
</tr>
</thead>
<tbody>
<?php
if($records){
foreach ($records as $record):
?>
<tr>
<td class="text-center align-middle">
<a href="<?php echo base_url('dashboard/editteen/'.$record->id); ?>" class="btn btn-primary "title="Edit Record">
<i class="fas fa-edit"></i>
</a>
</td>
<td class="text-center align-middle"><?php echo $record->lastname;?></td>
<td class="text-center align-middle"><?php echo $record->firstname;?></td>
<td class="text-center align-middle"><?php echo $record->middlename;?></td>
<td class="text-center align-middle"><?php echo $record->zone;?></td>
<td class="text-center align-middle">
<?php echo !empty($record->bday) ? date('m/d/Y', strtotime($record->bday)) : '';?>
</td>
<td class="text-center align-middle"><?php echo $record->age;?></td>
<td class="text-center align-middle"><?php echo $record->servicegive;?></td>
<td class="text-center align-middle">
<?php echo !empty($record->lmp) ? date('m/d/Y', strtotime($record->lmp)) : '';?>
</td>
<td class="text-center align-middle">
<?php echo !empty($record->edc) ? date('m/d/Y', strtotime($record->edc)) : '';?>
</td>
<td class="text-center align-middle"><?php echo $record->gpa;?></td>
<td class="text-center align-middle"><?php echo $record->remarks;?></td>
<td class="text-center align-middle"><?php echo $record->teenagepregnancy;?></td>
</tr>
down here is my code in importing
For loop in
if($sheetcount>1)
{
$data=array();
for ($i=1; $i < $sheetcount; $i++) {
$lastname=$sheetdata[$i][1];
$firstname=$sheetdata[$i][2];
$middlename=$sheetdata[$i][3];
$zone=$sheetdata[$i][4];
$bday=date('y-m-d',strtotime($sheetdata[$i][5]));
$age=$sheetdata[$i][6];
$servicegive=$sheetdata[$i][7];
$lmp=date('y-m-d',strtotime($sheetdata[$i][8]));
$edc=date('y-m-d',strtotime($sheetdata[$i][9]));
$gpa=$sheetdata[$i][10];
$remarks=$sheetdata[$i][11];
$teenagepregnancy=$sheetdata[$i][12];
set of data array
$data[]=array(
'lastname'=>$lastname,
'firstname'=>$firstname,
'middlename'=>$middlename,
'zone'=>$zone,
'bday'=>$bday,
'age'=>$age,
'servicegive'=>$servicegive,
'lmp'=>$lmp,
'edc'=>$edc,
'gpa'=>$gpa,
'remarks'=>$remarks,
'teenagepregnancy'=>$teenagepregnancy,
);
}
$inserdata=$this->m->insert_batch_teen($data);
if($inserdata)
{
$this->session->set_flashdata('message','<div class="alert alert-success">Successfully Added.</div>');
redirect('dashboard/importteen');
} else {
$this->session->set_flashdata('message','<div class="alert alert-danger">Data Not uploaded. Please Try Again.</div>');
redirect('dashboard/importteen');
}
}
}