Ali Rasheed
Ali Rasheed

Reputation: 2817

Is there a way to change timestamp of zend log to unix

I am currently using Zend framework 3 with zend log module. I noticed the Timestamp column of zend log table is not unix timestamp.

I have tried to search solution but all I could see the way to change format. It there a way to change it and store to unix timestamp?

Upvotes: 0

Views: 40

Answers (1)

Gautam Rai
Gautam Rai

Reputation: 2505

You can set your prefered time using setDateTimeFormat() to Formatter, as in below-

    $logger = new \Zend\Log\Logger();

    $formatter = new \Zend\Log\Formatter\Simple();
    $formatter->setDateTimeFormat('Y-m-d'); // as per your choice

    $writer = new \Zend\Log\Writer\Stream('php://output');
    $writer->setFormatter($formatter);
    $logger->addWriter($writer);

Upvotes: 0

Related Questions