How to set correct time when insert or update a record in MySQL DB

Hi all,

I’ve read in community about similar issue with time but there isn´t a recent answer about it. For this, I want to know how to insert/update a correct time based in user timezone.

Example: user 1 located in Bogota must set the time in GMT-5 but the user2 located in Argentina his time is GMT-3. The timezone must be transparant for the website, in other words, the time should be set based in user’s location.

Thanks in advance

You want to display a clock on your website based on user timezone? Or insert the current date and time in the database based on user timezone?

Hi @Oz29!

I’ve read in community about similar issue with time but there isn´t a recent answer about it. For this, I want to know how to insert/update a correct time based in user timezone.

MySQL uses by default the time-zone set by the server.

If you want to insert a specific time form another zone you must use PHP to generate the time and then insert it into the database.

1 Like