zoukankan      html  css  js  c++  java
  • Mysql 中日期类型bigint和datetime互转

    MySql数据库中字段类型bigint 长度是10位的

    mysql> select (from_unixtime(1554047999))as datatime;
    +---------------------+
    | datatime |
    +---------------------+
    | 2019-03-31 23:59:59 |
    +---------------------+
    1 row in set

    mysql> select (unix_timestamp('2019-03-31 23:59:59'))as unixtime;
    +------------+
    | unixtime |
    +------------+
    | 1554047999 |
    +------------+
    1 row in set

    如果bigint存储的是13位,因此转换时会有乘以1000及除以1000的操作

    mysql> select (from_unixtime(1556609724438/1000))as datatime;
    +--------------------------+
    | datatime |
    +--------------------------+
    | 2019-04-30 15:35:24.4380 |
    +--------------------------+

    具体到表里面查询

    mysql> select id,tested from table_A;
    +----+------------+
    | id | tested |
    +----+------------+
    | 6 | 1554859010 |
    | 7 | 1554859194 |
    +----+------------+

    mysql> select id,from_unixtime(tested)AS tested from table_A;
    +----+---------------------+
    | id | tested |
    +----+---------------------+
    | 6 | 2019-04-10 09:16:50 |
    | 7 | 2019-04-10 09:19:54 |
    +----+---------------------+

  • 相关阅读:
    集合
    字典
    列表
    事件兼容性封装
    E5中遍历数组的方法
    canvas绘制三等分饼型图
    canvas制作刮刮乐案例
    canvas绘制饼型图
    javascript中手风琴特效
    javascript中client()兼容性封装
  • 原文地址:https://www.cnblogs.com/shisanye/p/15058079.html
Copyright © 2011-2022 走看看