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 Answers1

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'))
Abhishek Sharma
  • 6,689
  • 1
  • 14
  • 20
  • ok. i still can't understand why in this specific date (all sat. and sun.), mysql give me wrong result. – user5549328 Nov 11 '15 at 05:50
  • 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: https://stackoverflow.com/questions/930900/how-do-i-set-the-time-zone-of-mysql – DonP May 18 '22 at 03:22