Unix time stamp conversion giving tow different result in mysql and oracle
select FROM_UNIXTIME(1387444958) from dual;
Output :2013-12-19 1
Unix timestamp is seconds from 1970-01-01 00:00:00 UTC
which is actually 1970-01-01 01:00:00
in your local timezone (or the timezone where your MySQL server is located). Looks like FROM_UNIXTIME
takes this into account.
For Oracle you can use this function:
FUNCTION UnixTime2Timestamp(UnixTime IN NUMBER) RETURN TIMESTAMP IS
BEGIN
RETURN (TIMESTAMP '1970-01-01 00:00:00 UTC' + UnixTime * INTERVAL '1' SECOND) AT LOCAL;
END UnixTime2Timestamp;
I assume if you like to get UTC time in MySQL then you have to run
select
CONVERT_TZ(FROM_UNIXTIME(1387444958),'{your local timezone}','UTC')
from dual;