symfony can’t export csv with date time data

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

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *