select datediff(ss, 'jan 1 1970', datetime_column) from ... #### use Time::Local; $time = timelocal(gmtime($time_from_database));