Open shemgp opened 6 years ago
I would like to reopen and put this issue here https://github.com/laravel/framework/issues/35135
I happen to face this issue too. The $dateFormat on Model only affects when we save the model but not when we need to query. My use case is when I want to query with a specific timezone and Y-m-d H:i:s format makes the timezone information truncated and returns wrong results. I think we need a way to configure this like doing Grammar::setDateFormat('Y-m-d H:i:s.uP') on AppServiceProvider, so I can override it when needed. Please consider this suggestion @driesvints, Thanks.
I usually add a timezone in my timestamps (created_at, updated_at, deleted_at). This requires me to set
protected $dateFormat
per model or have a custom base model that has the required format. However,pivot->withTimestamps()
won't follow those rules. Adding a global'date_format'
would fix the problem.The implementation is a simple:
in the
framework/Illuminate/Database/Grammar.php
.Thank you for considering this.