Replace SQL datetime by decimal(32,9) Unix epoch timestamps.
Change time representation to Unix epoch in code.
Format times with strftime().
Add contest starttime_string column.
Consistently use time print and diff functions.