vendredi 29 janvier 2016

Laravel Model protected $dateFormat - How to remove seconds?

Platform: Laravel 5.1

Database: MySQL

I'm also using Fractal Transformers for transforming my returned data to JSON objects.

After putting this protected $dateFormat = 'Y-m-d H:i'; in my Model(note the missing :s) Carbon is throwing errors:

exception 'InvalidArgumentException' with message 'Trailing data' in C:\project1\vendor\nesbot\carbon\src\Carbon\Carbon.php:425

According to the documentation this should work: http://ift.tt/1m1Ra3D

I've tried the following:

  • Change my MySQL table structure from TIMESTAMP to DATETIME- no change
  • Changing the returned value with substr($time, 0, -3) - got errors
  • Asking in Gitter for help, got this:

I might be using a different Persistence that doesn't use the MySQL format

What does this mean?

How do I make sure Carbon::now() or MySQL is creating timestamps without seconds?

OR

How do I return only Y-m-d H:i?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire