makapaka
2 months ago
129
4
Laravel

Datetime I think I'm saving is created wrong in DB

Posted 2 months ago by makapaka

I am using php to on the fly set timezone, and create a date:

$time = (new DateTime("now", new DateTimeZone('Australia/Sydney')));

When I print this out to screen, its perfect, as I expect.

However when I create the object using query builder and use it as the date, the date saved is using wrong timezone, basically not taking the date that is printed to screen

      $team->league()->create([
            'round' => 1
            'time' => $time->format('Y-m-d H:i:s')
        ]);

Any ideas or suggestions how to debug ? Is query builder doing something else with the date I don't know about ? thanks

Please sign in or create an account to participate in this conversation.