Home:ALL Converter>Mysql Unix_timestamp function

Mysql Unix_timestamp function

Ask Time:2012-07-26T19:54:27         Author:jhon.smith

Json Formatter

In oracle converting this date 2012-07-03 11:38:41 to unix_timestamp we get

    select (to_date('2012-07-03 11:38:41','YYYY-MM-DD HH24:MI:SS') -
    to_date('1970-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'))*86400 as unix_timestamp
    from dual
SQL> /

UNIX_TIMESTAMP
--------------
    1341315521

But when i try the same on mysql server

select UNIX_TIMESTAMP('2012-07-03 11:38:41')
1341311921

Server Settings are something like this

**mysql**> select current_timestamp();
+---------------------+
| current_timestamp() |
+---------------------+
| 2012-07-26 15:27:31 |
+---------------------+
1 row in set (0.00 sec)

**Unix** >Thu Jul 26 15:27:56 BST 2012

**oracle**>select current_timestamp from dual;

CURRENT_TIMESTAMP
------------------------------------
26-JUL-12 15.27.16.967258 +01:00

How do i make sure oracle and mysql give me the same values ?

Author:jhon.smith,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/11668731/mysql-unix-timestamp-function
Pekka :

The difference between the two values you show is 3600 seconds, i.e. 1 hour.\n\nMost likely, the two servers' timezone settings vary by one hour.\n\nSee https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html for time zone info in the mySQL server. Here is some in-depth info for Oracle's handling of time zones.",
2012-07-26T11:58:28
yy