0

I make an insert using now() as default, and when i look in the table it says for example 11:00, and when i click on it, it specifies the timezone (+3:00). Which means that it equals 8:00 UTC+0. Which is WRONG, because I actually made that insert at 11:00 UTC+0.

More strangely, when I try "SET time_zone = '+9:00'" or no matter which timezone I specify, it doesn't change ANYTHING - now() still creates the wrong timestamp with with UTC+3.

If I just write a single query "SET time_zone = '+3:00'; SELECT now()", it returns the correct value.

But if I write "SET time_zone = '+3:00'; update table set time=now() where id=11", and then check the table, the problem appears again.

I'm using 000webhost.

Please help? It drives me insane.

pancake
  • 61
  • 4
  • What is the timezone of the host machine – hardillb Aug 17 '18 at 12:10
  • _"Which means that it equals 11:00 UTC+0. Which is WRONG, because I actually made that insert at 11:00 UTC+0."_ Um.. – Lightness Races in Orbit Aug 17 '18 at 12:11
  • What is the type of your field? Is it a `DATETIME` or a `TIMESTAMP`? Have you read the documentation for the type you're using? – Lightness Races in Orbit Aug 17 '18 at 12:12
  • You can't "click on" things in a MySQL database. You're using some GUI or interface. Please provide a concrete example in the form of a [MCVE]. – Lightness Races in Orbit Aug 17 '18 at 12:12
  • I don't know what the timezone of the host machine is, but it's not supposed to matter because the host machine is supposed to know the correct UTC time, which seems like it doesn't. The type of my field is TIMESTAMP. Yes I've been googling about it all over trying to solve this problem. I use phpmyadmin – pancake Aug 17 '18 at 12:15
  • 1
    maybe read doc - https://stackoverflow.com/a/7703874/5585424 – Ankush Rathi Aug 17 '18 at 12:17
  • Executing "SET time_zone = x" will only change the timezone for your current connection. You have to change it global (SET GLOBAL time_zone = x) to persist it for other connections. The standard timezone mysql tries to determine from your host machine. – Demigod Aug 17 '18 at 13:06

0 Answers0