from_second

description

Syntax

DATETIME FROM_SECOND(BIGINT unix_timestamp) DATETIME FROM_MILLISECOND(BIGINT unix_timestamp) DATETIME FROM_MICROSECOND(BIGINT unix_timestamp)

将时间戳转化为对应的 DATETIME,传入的是整型,返回的是DATETIME类型。若unix_timestamp < 0 或函数结果大于 9999-12-31 23:59:59.999999,则返回NULL

example

  1. mysql> set time_zone='Asia/Shanghai';
  2. mysql> select from_second(-1);
  3. +---------------------------+
  4. | from_second(-1) |
  5. +---------------------------+
  6. | NULL |
  7. +---------------------------+
  8. mysql> select from_millisecond(12345678);
  9. +----------------------------+
  10. | from_millisecond(12345678) |
  11. +----------------------------+
  12. | 1970-01-01 11:25:45.678 |
  13. +----------------------------+
  14. mysql> select from_microsecond(253402271999999999);
  15. +--------------------------------------+
  16. | from_microsecond(253402271999999999) |
  17. +--------------------------------------+
  18. | 9999-12-31 23:59:59.999999 |
  19. +--------------------------------------+
  20. mysql> select from_microsecond(253402272000000000);
  21. +--------------------------------------+
  22. | from_microsecond(253402272000000000) |
  23. +--------------------------------------+
  24. | NULL |
  25. +--------------------------------------+

keywords

  1. FROM_SECOND,FROM,SECOND,MILLISECOND,MICROSECOND