取得当前时间用 now() 就行。
在数据库中格式化时间 用DATE_FORMA T(date, format) .
根据格式串format 格式化日期或日期和时间值date,返回结果串。 可用DATE_FORMAT( ) 来格式化DATE 或DATETIME 值,以便得到所希望的格式。根据format字符串格式化date值: %S, %s 两位数字形式的秒( 00,01, . . ., 59) %i 两位数字形式的分( 00,01, . . ., 59) %H 两位数字形式的小时,24 小时(00,01, . . ., 23) %h, %I 两位数字形式的小时,12 小时(01,02, . . ., 12) %k 数字形式的小时,24 小时(0,1, . . ., 23) %l 数字形式的小时,12 小时(1, 2, . . ., 12) %T 24 小时的时间形式(h h : m m : s s) %r 12 小时的时间形式(hh:mm:ss AM 或hh:mm:ss PM) %p AM 或P M %W 一周中每一天的名称( S u n d a y, Monday, . . ., Saturday) %a 一周中每一天名称的缩写( Sun, Mon, . . ., Sat) %d 两位数字表示月中的天数( 00, 01, . . ., 31) %e 数字形式表示月中的天数( 1, 2, . . ., 31) %D 英文后缀表示月中的天数( 1st, 2nd, 3rd, . . .) %w 以数字形式表示周中的天数( 0 = S u n d a y, 1=Monday, . . ., 6=Saturday) %j 以三位数字表示年中的天数( 001, 002, . . ., 366) % U 周(0, 1, 52),其中Sunday 为周中的第一天 %u 周(0, 1, 52),其中Monday 为周中的第一天 %M 月名(J a n u a r y, February, . . ., December) %b 缩写的月名( J a n u a r y, February, . . ., December) %m 两位数字表示的月份( 01, 02, . . ., 12) %c 数字表示的月份( 1, 2, . . ., 12) %Y 四位数字表示的年份 %y 两位数字表示的年份 %% 直接值“%” select date_format(日期字段,’%Y-%m-%d’) as ‘日期’ from test

MySQL取得当前时间的函数是什么 格式化日期的函数是什么的更多相关文章

  1. mysql格式化日期的函数

    转自:https://www.cnblogs.com/duhuo/p/5650876.html mysql格式化日期   mysql查询记录如果有时间戳字段时,查看结果不方便,不能即时看到时间戳代表的 ...

  2. Java 格式化日期、时间

    有三种方法可以格式化日期.时间. 1.使用DateFormat类 获取DateFormat实例: DateFormat.getDateInstance()    只能格式化日期      2019年5 ...

  3. MySQL 获得当前日期时间\时间戳 函数 ( 转自传智播客)

    MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +-------+ | now() | +-- ...

  4. MySQL 获得当前日期时间 函数

    获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+ | now() | +---------- ...

  5. MySQL时间戳和时间格式转换函数

    MySQL时间戳和时间格式转换函数:unix_timestamp and from_unixtime unix_timestamp将时间转化成时间戳格式.from_unixtime将时间戳转化成时间格 ...

  6. MySQL 获得当前日期时间 函数【转】

    获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+ | now() | +---------- ...

  7. (转)MySQL 获得当前日期时间 函数

    select *from High_valwhere SerialDate >= curdate() and SerialDate < date_add(curdate(), interv ...

  8. MySQL 获得当前日期时间\时间戳 函数

    MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +———————+ | now() | +—— ...

  9. mysql加减时间-函数-时间加减

    select timediff('23:40:00', ' 18:30:00'); -- 两时间相减 SELECT substring( timediff(,) ----“:”相减返回小时:分钟 -- ...

随机推荐

  1. python基础之 list和 tuple(元组)

    list Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. 比如,列出班里所有同学的名字,就可以用一个list表示: >>> ...

  2. Populating Next Right Pointers in Each Node,Populating Next Right Pointers in Each Node II

    Populating Next Right Pointers in Each Node Total Accepted: 72323 Total Submissions: 199207 Difficul ...

  3. Centos7安装JDK

    以下是gz包方式: 1,将jdk-8u51-linux-x64.tar.gz放到/usr/java目录下 2,用tar -zxvf jdk-8u51-linux-x64.tar.gz 解压到当前目录 ...

  4. Activiti+oracle 启动项目时不能自动建表或更新表的问题分析及解决办法

    现象描述:按照正常配置,第一次启动时不能自动建表 关键配置片段如下: <bean id="processEngineConfiguration" class="or ...

  5. Java GC机制和对象Finalize方法的一点总结

    GC是垃圾收集的意思(Garbage Collection),内存处理是编程人员容易出现问题的地方,忘记或者错误的内存回收会导致程序或系统的不稳定甚至崩溃,Java提供的GC功能可以自动监测对象是否超 ...

  6. 解析XML【C#】

     1.XML元素XML元素包含一个开标记.元素中的数据.闭标记例如:<book>book name</book>其中book是元素名称  book name是元素数据元素名称区 ...

  7. accel-pptp 部署

    accel-pptp 是 pptp-client 和 pptpd 的改进版,使用内核 pptp 模块,相比 raw socket 实现方式能提供更好的性能.   Ubuntu 12.04 上启用内核 ...

  8. [Leetcode][Python]42: Trapping Rain Water

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 42: Trapping Rain Waterhttps://oj.leetc ...

  9. poj 1065 Wooden Sticks_贪心

    题意:将木棍放在机器里处理,第一根需要一分钟,剩余的如果大于等于前边放入的长度和重量,就不用费时间,否则需要一分钟,计算给出一组数的最少时间. 思路:先按长度排序,相同在比较重量,然后按顺序比较得出结 ...

  10. ios中block中的探究

    http://blog.csdn.net/jasonblog/article/details/7756763