symfony can’t export csv with date time data

  csv, symfony, symfony-3.4

Can’t export file to CSV when have this line $row->getcreateAt()

$response = new StreamedResponse();
        $response->setCallback(
            function () use ($results) {
                $handle = fopen('php://output', 'w+');
                foreach ($results as $row) {
                    //array list fields you need to export
                    $data = [
                        $row->getId(),
                        $row->getcreateAt(),
                        $row->getPtfName(),
                    ];
                    fputcsv($handle, $data);
                }
                fclose($handle);
            }
        );

Source: Symfony Questions

LEAVE A COMMENT