Sunday, March 19, 2017

Laravel datetime returned from database is different from records in the same database

Long story short:

public function betweenDate($startDate,$startTime,$endDate,$endTime){

      return DB::table('tablice')->where([['datum', '>', $startDate." ".$startTime], ['datum', '<', $endDate." ".$endTime]])->get();

    }

I need to search records in database between dates, and this code works, but with one simple error. Returned date looks like this ... {"id":62667,"br_tablice":"LK493","moguce_tablice":"LK493,LK8493,LK4293,LK4J93,LK893,L8493,LKB493,","ostalo":null,"datum":"2017-03-17 19:00:14"} .... Returned date is 2017-03-17 19:00:14 but in database is 2017-03-17 20:00:14, and I cant figure it out why. In .env I set APP_TIMEZONE=CET, the same as database uses. Changing timezone doesn't work, because I tried with every timezone.



via Aleksandar

Advertisement