laravel-couchdb
laravel-couchdb copied to clipboard
Default date format should be ISO 8601
Hi, I'm building an API gateway with Lumen 5.4 (btw, it works!) and the database is feeded by an iOS application with Couchbase Lite library. The datetime format used in Model.php ('Y-m-d H:i:s') mimics the format used by MySql and is not in the standard format used in CouchDB (for example "2018-05-04T11:40:52.280Z"). Is there a reason for this decision? Thanks!
Ok, I found a way to override the default format. I've added the following code snippet in my model definition:
protected function serializeDate(\DateTimeInterface $date) { return $date->format('c'); }
Unfortunately, this was a bad decision I had when I was building the application which I completely regret.
The default date format should be ISO 8601 so I am reopening and renaming this issue to fix it later.
You can define your personal date format on your model, though.
protected $dateFormat = 'l jS \of F Y h:i:s A';