Got an example of the sql query? Which sql? (eg. MySQL?) Sounds like it's showing UTC (GMT) time.
I know PHP will use unix time and has to be compensated for, but I think(!) SQL also goes on the server time rather than the moodle system time? So it's entirely possible to get three different times depending on which method you use?
Pretty sure all time data written to the database is in the moodle system time though.