zoukankan      html  css  js  c++  java
  • mysql 获取系统时间及其格式

    mysql>select   now();

    +---------------------+ |

    now()               | +---------------------+

    | 2011-06-11 12:00:54 | +---------------------+ 1 row in set (0.00 sec)

     

     

    mysql>select   sysdate();

    +---------------------+ | sysdate()           | +---------------------+ |2011-06-11 12:00:54 | +---------------------+ 1 row in set (0.00 sec)

     

     

    mysql>select   curdate(); +------------+ | curdate()  | +------------+ |2011-06-11 | +------------+ 1 row in set (0.00 sec)

     

     

    mysql> select   current_date; +--------------+ | current_date | +--------------+ |2011-06-11   | +--------------+ 1 row in set (0.00 sec)

     

     

    mysql> select   curtime(); +-----------+ | curtime() | +-----------+ | 12:00:54  | +-----------+ 1 row in set (0.00 sec)

     

     

     

    mysql>select   current_time; +--------------+ | current_time | +--------------+ |12:00:54     | +--------------+ 1 row in set (0.00 sec)

     

    2. mysql (unix 时间戳、日期)转换函数:

    unix_timestamp(),unix_timestamp(date),from_unixtime(unix_timestamp),from_unixtime(unix_timestamp,format)

    下面是示例:

    select unix_timestamp(); -- 1218290027 ===得到当前时间的unix时间值

    将具体时间来转换成timestamp

    select unix_timestamp('2008-08-08'); -- 1218124800select unix_timestamp('2008-08-08 12:30:00'); -- 1218169800

    将timestamp来转换成具体时间select from_unixtime(1218290027); -- '2008-08-09 21:53:47'select from_unixtime(1218124800); -- '2008-08-08 00:00:00'select from_unixtime(1218169800); -- '2008-08-08 12:30:00'

    select from_unixtime(1218169800, '%y %d %m %h:%i:%s %x'); -- '2008 8th august 12:30:00 2008'

  • 相关阅读:
    Mongoose使用
    Koa原理和封装
    微信用户授权
    Koa微信公众号开发
    Koa2+mongoose
    NodeJS-API
    jquery下json数组的操作用法实例
    SqlCacheDependency:asp.net SQL缓存依赖
    SqlCacheDependency轮询数据库表的更改情况的频率
    设置浏览器地址栏URL前面显示的图标
  • 原文地址:https://www.cnblogs.com/lcuzhanglei/p/2605177.html
Copyright © 2011-2022 走看看