0
insert into wp_processed values ('306186837','John Wick','Marketplace','2020-06-19 12:21:10','My Dog T-Shirt','5XL','Green','1','79');

And when I select the inserted row it shows that date data is inserted with +3 hours.

2020-06-19 15:21:10

What am I missing ?

Thanks

HOY
  • 1,187
  • 9
  • 40
  • 74
  • 1
    What's you local timezone? What's the timezone on your MySQL server? – Dougie Jun 20 '20 at 00:57
  • timezone GMT +3, in MySQL it says SYSTEM, I am not sure but seem like it is UTC – HOY Jun 20 '20 at 00:58
  • 1
    What is the type of the column? – Nick Jun 20 '20 at 01:02
  • datetime, mysql seems to change timezone for inserted string automatically to UTC, I am trying to prevent this on insert. – HOY Jun 20 '20 at 01:04
  • 1
    There you go. The MySQL server is storing your data as GMT/UTC. So you'll need to get it back to your local timezone when you select it. `SELECT CONVERT_TZ(date_col, '+0:00', '+3:00') FROM wp_processed;` – Dougie Jun 20 '20 at 01:21
  • @Dougie when I save to database, it automaticall adds 3 hours, and your CONVERT_TZ also adds 3 hours. So final result is 6 hours difference. My local time is gmt +3, I can get what I want by changing it to -3 of course. But I want to do it proper way, and by understanding. – HOY Jun 20 '20 at 10:13
  • Are you East or West of Greenwich? – Dougie Jun 20 '20 at 22:32
  • server is in amsterdam, and my location is in istanbul. – HOY Jun 21 '20 at 23:22

0 Answers0