1

can anybody explain me how this Mysql query result is possible.

select 
sec_to_time(
unix_timestamp('2014-10-26 02:00:00')-
unix_timestamp('2014-10-25 20:00:00')
);

result:

07:00:00

should be:

06:00:00
1
  • daylight saving time? It is saturday and sunday... Commented Nov 11, 2015 at 5:34

1 Answer 1

2

Use MySQL TIMEDIFF or TIME_TO_SEC like that :-

TIME_TO_SEC(TIMEDIFF('2014-10-26 02:00:00', '2014-10-25 20:00:00'))
Sign up to request clarification or add additional context in comments.

2 Comments

ok. i still can't understand why in this specific date (all sat. and sun.), mysql give me wrong result.
Apparently your server's time zone is not set or is set improperly and you're getting GMT rather than local time. More about that here: stackoverflow.com/questions/930900/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.