lundi 20 août 2018

How to make all database changes follow UTC timezone?

I'm using Laravel 5.5 with MySQL all hosted on AWS.

I set timezone to be UTC in app.php also the time in server is UTC when I run the date command.

However, when I delete a model object from the app's dashboard, the updated_at is set to the time of my computer instead of UTC. That said, the deleted_at is set to UTC! it's just the updated_at I have issue with.

This is the code the deletes the object in Laravel:

/**
 * Remove the specified resource from storage.
 *
 * @param $eventId
 *
 * @return Response
 *
 * @internal param int $id
 */
public function destroy( $eventId ) {
    $this->eventsService->dashboard->delete( $eventId );
    flash( 'Event has been deleted', 'success' );
    if ( str_contains( $_SERVER['HTTP_REFERER'], 'events/' . $eventId . '/edit' ) ) {
        return redirect( '/events' );
    }

    return redirect( $_SERVER['HTTP_REFERER'] );
}

This is from app.php:

'timezone'        => 'UTC',

This is when I run date on server:

Tue Aug 21 04:48:42 UTC 2018

This is a scheduled job that updated the status of events (The app is for travel experiences) from future to current ...etc, it uses the Carbon package:

$schedule->command(EventsUpdateStatus::class)->everyMinute();

What else to check to ensure updated_at follows UTC?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire