lundi 6 septembre 2021

Laravel Eloquent filter by MySQL Timestamp

I have a Laravel (5.2) Eloquent Model where the database field type is MySQL Timestamp and having values in Y-m-d H:i:s format,

I am wiring some Laravel Eloquent model as:

UserSubscription::where('renewal_date','<=',Carbon::now());

but when I print this using toSql() , the query print ? instead Carbon::now() value, I also tried below options by replacing Carbon::now() with:

  1. Carbon::now('UTC') I already have timezone defined in my config file as UTC.

  2. Carbon::now()->format('Y-m-d H:i:s')

  3. Carbon::now()->toDateTimeString()

  4. date('Y-m-d H:i:s')

but nothing worked, where and what I am doing wrong..?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire