0 votes
413 views
by (1.5k points)
Whenever, I insert date into MySQL database, it automatically convert the local date & time (in my case Indian time zone) to UTC (Universal Time) also known as GMT.

I want to save date & time as it is, instead of auto conversion into UTC by MySQL.

1 Answer

0 votes
by (10.3k points)

Yes, in most case MySQL follows system time zone. If your system or server has set to UTC time zone as default then every inserted date-time field will be automatically converted into to the UTC automatically. 

You can either set/change timezone of system or MySQL. Or simply alter Insert (or EDIT, DELETE) query like below.

INSERT INTO tbl_name (date_time, first_name, last_name) VALUES (CONVERT_TZ(date_time_value,'+00:00','+05:30'), first_name, last_name)

It will save your Indian time as it is. 

...