EsgynDB 函数之unix_timestamp及from_unixtime

在EsgynDB 2.5版本及后续版本中,支持了对MySQL数据库中unix_timestamp及from_unixtime函数的兼容性实现。

  • unix_timestamp 用于得到一个固定timestamp对应的unix timestamp值,类型为整形。
  • from_unixtime用于从一个固定的unix timestamp值来获取对应的timestamp时间戳,类型为timestamp。

UNIX_TIMESTAMP用法

//返回当前时间的unix timestamp值
>>select unix_timestamp() from dual;

(EXPR)              
--------------------

          1556513782

--- 1 row(s) selected.

//返回固定日期的unix timestamp值,2019-04-29等同于2019-04-29 00:00:00
>>select unix_timestamp('2019-04-29') from dual;

(EXPR)              
--------------------

          1556496000

--- 1 row(s) selected.

//返回固定时间戳的unix timestamp值
>>select unix_timestamp('2019-04-29 12:58:59') from dual;

(EXPR)              
--------------------

          1556542739

--- 1 row(s) selected.

//指定格式并返回固定时间戳的unix timestamp值
>>select unix_timestamp('2019-04-29 12:58:59','YYYY-MM-DD HH24:MI:SS') from dual;

(EXPR)              
--------------------

          1556542739

--- 1 row(s) selected.

FROM_UNIXTIME用法

//返回固定unix timestamp值对应的timestamp时间戳
>>select from_unixtime('1556496000') from dual;

(EXPR)             
-------------------

2019-04-29 00:00:00

--- 1 row(s) selected.
>>select from_unixtime('1556542739') from dual;

(EXPR)             
-------------------

2019-04-29 12:58:59

--- 1 row(s) selected.

你可能感兴趣的:(EsgynDB 函数之unix_timestamp及from_unixtime)