laravel-couchdb icon indicating copy to clipboard operation
laravel-couchdb copied to clipboard

Default date format should be ISO 8601

Open ecordani opened this issue 6 years ago • 2 comments

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!

ecordani avatar May 04 '18 14:05 ecordani

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'); }

ecordani avatar May 04 '18 16:05 ecordani

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';

robsonvn avatar May 07 '18 03:05 robsonvn