{"action":"closed","issue":{"url":"https://api.github.com/repos/Seldaek/monolog/issues/642","labels_url":"https://api.github.com/repos/Seldaek/monolog/issues/642/labels{/name}","comments_url":"https://api.github.com/repos/Seldaek/monolog/issues/642/comments","events_url":"https://api.github.com/repos/Seldaek/monolog/issues/642/events","html_url":"https://github.com/Seldaek/monolog/issues/642","id":105401894,"number":642,"title":"How to save datetime field in ISODate format instead of seconds ","user":{"login":"stonecold123","id":9678061,"avatar_url":"https://avatars.githubusercontent.com/u/9678061?v=3","gravatar_id":"","url":"https://api.github.com/users/stonecold123","html_url":"https://github.com/stonecold123","followers_url":"https://api.github.com/users/stonecold123/followers","following_url":"https://api.github.com/users/stonecold123/following{/other_user}","gists_url":"https://api.github.com/users/stonecold123/gists{/gist_id}","starred_url":"https://api.github.com/users/stonecold123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonecold123/subscriptions","organizations_url":"https://api.github.com/users/stonecold123/orgs","repos_url":"https://api.github.com/users/stonecold123/repos","events_url":"https://api.github.com/users/stonecold123/events{/privacy}","received_events_url":"https://api.github.com/users/stonecold123/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-08T15:07:11Z","updated_at":"2015-09-21T17:29:09Z","closed_at":"2015-09-21T17:29:09Z","body":"I have been using a php IDS system `expose` that uses monolog to store logs into MongoDB. I'm trying to change the `datetime` field to ISODate format so that I can use the  MongoDB’s “time to live” or TTL collection feature to delete logs.\r\n\r\nHere's the part responsible for storing datetime in `\\Expose\\Log\\Mongo();`\r\n\r\n````\r\npublic function log($level, $message, array $context = array())\r\n{\r\n    $logger = new \\Monolog\\Logger('audit');\r\n    try {\r\n        $handler = new \\Monolog\\Handler\\MongoDBHandler(\r\n            new \\MongoClient($this->getConnectString()),\r\n            $this->getDbName(),\r\n            $this->getDbCollection()\r\n        );\r\n    } catch (\\MongoConnectionException $e) {\r\n        throw new \\Exception('Cannot connect to Mongo - please check your server');\r\n    }\r\n    $logger->pushHandler($handler);\r\n    $logger->pushProcessor(function ($record) {\r\n        $record['datetime'] = $record['datetime']->format('U');            \r\n        return $record;\r\n    });\r\n    return $logger->$level($message, $context);\r\n}\r\n````\r\n\r\nI have changed `$record['datetime'] = $record['datetime']->format('U');  ` to \r\n\r\n`$record['datetime'] = new \\MongoDate();`\r\n\r\nbut the timestamp is stored as \r\n````\r\n\"datetime\": \"[object] (MongoDate: 0.84500000 1441721683)\"\r\n````\r\ninstead of \r\n\r\n````\r\n\"datetime\":ISODate(\"2015-09-08T17:43:25.678Z\");\r\n````\r\n\r\nHow can I get the `datetime` to store in ISODate format instead of seconds? \r\n"}}