Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
MySQL stores wrong timestamp

I am using Laravel 6. I have created a ticketing system and successfully uploaded on server.

I am storing ticket creation time in created_at field in my MySQL database. The problem is sometimes the timestamp in created_at field is correct and sometimes it stores wrong timestamp.

The problem is weird and I cannot figure it out and don't know how to debug this issue.

My timezone in Laravel config/app.php is set to Asia/Kolkata

'timezone' => 'Asia/Kolkata',

Here is my ticket create method

$ticket_tracker = TICKET_TRACKER::create
        ([
            'ticket_no' => $ticket_number,
            'partner_id' => $partner_id,
            'team_id'   => $team_id,
            'priority_id'   => $priority_id,
            'opened_date'   => $opened_date,
            'created_by'   => $user_id,
        ]);

created_at field is not included in above code as Laravel stores time itself.

Table Structure

enter image description here

After further digging into issue I have discovered that MySQL stored correct timestamp when I created a ticket for testing. After few hours I have created the another ticket which is saved with correct timestamp but timestamp of my old ticket changed itself (I don't know how this happened).

Also I found that my global and session time zone is system which is UTC I think because my current time is 5.30 hour ahead of timestamp displayed by this command CURRENT_TIMESTAMP

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Because you not provide created_at & updated_at values by you query the values is generated on MySQL side according MySQL server time and timezone. For check get MySQL current time use next simple query:

SELECT @@global.time_zone, @@session.time_zone, CURRENT_TIMESTAMP;

If CURRENT_TIMESTAMP is not match to your time zone you can change timezone settings following documentation

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda