I'm using PHP 7.2, MS SQL Server, fpdf, and phpSpreadsheet to create PDF and Excel reports of my data. Initially I had trouble returning the timestamp (date) fields in the reports, but adding "ReturnDatesAsStrings"=>true
in my connection.php solved that problem.
The issue now is that the date fields on the reports have a decimal and zeros added and show up as 2018-03-01 16:43:19.0000000
. How can I stop the addition of .0000000
? I'm not sure if it makes it any more complicated that it also needs to work with fpdf and phpSpreadsheet, but I included that info just in case.
UPDATE: Zhorov's first answer was right. I removed "ReturnDatesAsStrings"=>true
from connection.php and the phpSpreadsheet files work great! On the fpdf files, I had to add in '$date_as_string = date_format($data['created_date'], 'Y-m-d H:i:s');' and then the PDFs work too.
FINAL SOLUTION: NULL values were causing a problem, but Zhorov's fix worked. Had to add $date_as_string = is_null($row['DateField']) ? '' : date_format($row['DateField'] , 'Y-m-d H:i:s');