Issues with calculating timestamp difference :: MYSQL

MySQL information.
Post Reply
dzcadii
Posts: 94
Joined: Sun Mar 01, 2015 4:36 am

Issues with calculating timestamp difference :: MYSQL

Post by dzcadii » Sat Mar 07, 2015 5:36 pm

MYSQL version: 5.5.32 and 5.6.22

If you are using an older version of MYSQL and are trying to calculate; lets say seconds from 2 times. The easiest way I've found is:

Issue:
  1. data type set as bigint(64)
  2. using 2 different versions of MYSQL

using version 5.6.22 using CURRENT_TIMESTAMP will work in the calculation but it will not work on 5.5.32. So:

use: unix_timestamp(now()) in your calculations

example would be to see if an event happened within an hour: unix_timestamp(now()) - eventTime <= 3600

Post Reply