Hardip Raj
Hardip Raj

Reputation: 13

Current timestamp in mySQL is delayed by 30 minutes

I am trying to catch the current time by using current_timestamp query.

But it is returning the time delayed by 30 minutes.

So if there is any way to get the right time? Or can I increment time automatically.

I have used this syntax.

Data type of time is DATETIME. and also tried TIMESTAMP.

 UPDATE mytable SET time=CURRENT_TIMESTAMP WHERE id=1;

Upvotes: 1

Views: 1753

Answers (1)

patelb
patelb

Reputation: 2581

This is most likely occurring because of the system timezone offset.

run this query to get the timezone offset of the system that mysql is running on

select timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00'));

compare it with the timezone you are in.

Alternately you can run the following to get the correct time (replace the timezone with yours), but this means you would have to do it for every session.

SET time_zone='-06:00';
SELECT CURRENT_TIMESTAMP;

Upvotes: 1

Related Questions