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

151
Views
manage timezones JS difference of two hours

frontend side I send axios this date away:

Mon Jun 13 2022 18:29:00 GMT+0200 (Ora legale dell’Europa centrale)

because the backend (laravel 8.x) side saves me the usual one as follows:

2022-06-13 16:29:00

I wish he would save me 18:29 and not 16:29

how can i handle this? i can't install libraries like moment.js

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

This will likely be due to your app timezone being set to UTC. I personally would recommend storing everything in UTC and converting that for display purposes on the front end.

However, if you must store them in the same format, you'll need to set the timezone in config/app.php

/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/

'timezone' => 'UTC', <--- Change this to your timezone eg: Africa/Cairo

Select the correct timezone from this list.

Timezones available for GMT+0200

Don't forget to run php artisan config:clear to ensure your timezone configuration changes are being used.

about 4 years ago · Juan Pablo Isaza Report

0

I solved as follows:

    return new Date(year, month - 1, day, hours, minutes, seconds).toString().slice(0, 24);

can you do better?

about 4 years ago · Juan Pablo Isaza 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!