zoukankan      html  css  js  c++  java
  • MySQL(Unix时间戳、日期)转换函数

    unix_timestamp()

    mysql> select unix_timestamp();
    +------------------+
    | unix_timestamp() |
    +------------------+
    |       1464590043 |
    +------------------+
    

    unix_timestamp(date)

    mysql> select unix_timestamp('2016-05-30');
    +------------------------------+
    | unix_timestamp('2016-05-30') |
    +------------------------------+
    |                   1464537600 |
    +------------------------------+
    
    mysql> select unix_timestamp('2016-05-30 14:35:21');
    +---------------------------------------+
    | unix_timestamp('2016-05-30 14:35:21') |
    +---------------------------------------+
    |                            1464590121 |
    +---------------------------------------+
    

    from_unixtime(unix_timestamp)

    mysql> select from_unixtime(1464590043);
    +---------------------------+
    | from_unixtime(1464590043) |
    +---------------------------+
    | 2016-05-30 14:34:03       |
    +---------------------------+
    

    from_unixtime(unix_timestamp,format)

    mysql> select from_unixtime(1464590043, '%Y %D %M %h:%i:%s %x');
    +---------------------------------------------------+
    | from_unixtime(1464590043, '%Y %D %M %h:%i:%s %x') |
    +---------------------------------------------------+
    | 2016 30th May 02:34:03 2016                       |
    +---------------------------------------------------+
    
  • 相关阅读:
    JavaSE-集合的遍历
    JavaSE-Collection常用方法
    JavaSE-异常
    JavaSE-匿名类_匿名内部类的使用
    JavaSE-内部类
    JavaSE-接口应用举例
    java线程的使用(Runnable)
    list根据所存对象属性排序
    Unable to locate appropriate constructor on class异常
    redis在java项目中的使用
  • 原文地址:https://www.cnblogs.com/abclife/p/5542427.html
Copyright © 2011-2022 走看看