Issue
$row['A']
contains 13/03/2019
PHPExcel_Shared_Date::ExcelToPHP(trim($row['A']));
return float value
But date()
function in PHP
takes int
date('Y-m-d',PHPExcel_Shared_Date::ExcelToPHP(trim($row['A'])));
so it return 0
var_dump(PHPExcel_Shared_Date::ExcelToPHP(trim($row['A'])));exit();
showing result :float(2087015296)
print_r(intval(PHPExcel_Shared_Date::ExcelToPHP(trim($row['A']))));exit();
showing result: 2087015296
print_r(date('Y-m-d',2087015296));exit();
showing result 2036-02-19
Solution
You need to convert $row['A']
data to php acceptable date format,
After that pass it directly to date()
function to change it's format in your desired way
echo date('Y-m-d', strtotime(trim(str_replace('/','-',$row['A']))));
Output:-https://3v4l.org/beUIG
Answered By - Anant Kumar Singh
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.