#Problem with time synchronization in the database

7 messages · Page 1 of 1 (latest)

hidden furnace

Background
I have a game in which there is a functionality for carrying out pharmacy deliveries for various fractions, for the convenience of carrying out an order, I decided to write a bot that can automate the process. But I have the following problem: when ordering delivery at 23:59 on 01.05.2023, the time is moved forward 3 hours and postponed to the next day 2023-05-03 02:59:00. I reviewed the entire code and was left wondering why this is happening.

I use the mysql phpmyadmin database, and use sequelize to access the database.

The command accepts 3 arguments as input:

  1. The number of first aid kits
  2. time in the format "HH:MM"
  3. Screenshot of the warehouse as an attachment.

During the order, the time in the format "HH:MM" is changed to the format "YYYY-MM-DD HH:mm:ss" using this function - https://sourceb.in/LITvBtkBjn

As a result, if you place an order at 23:59 02.05, it will display the time in the database 2023-05-03 02:59:00

P.S The database and the bot are all contained on the same VPS host. Local time on OS +3 UTC is the same as in the database.
P.S.S I tried to place an order on a local computer and everything works perfectly, but on the host, why is the time postponed 3 hours ahead.

Please help if you know the solution to the problem

opaque kindle

The time your users input is not localized so your host (depending on the functions you use) interpretes them in the timezone it‘s in but your users probably enter them as UTC times

But if you use a Date type in your DB you shouldn’t use a string like that to insert it into the DB but an actual Date

hidden furnace
opaque kindle

You don’t specify the timezone in the string you make though. That’s why it assumes it’s in UTC

hidden furnace