Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!