取得当前时间用 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. SQL Server服务启动失败,错误代码:10048

    今天打开电脑后遇到了一个奇葩的问题,启动Sql Server服务时,出现如下图所示错误:

  2. js 去掉空格

    写成类的方法格式如下:(str.trim();)<script language="javascript"> String.prototype.trim=functio ...

  3. HtmlHelp

    @Html.Label("Label", "Label") @*渲染成<label for="Label">Label</ ...

  4. Oracle 11g完全卸载(Windows)(转)

    Oracle 11g完全卸载(Windows) 1.关闭oracle所有的服务.可以在windows的服务管理器中关闭:    一般有以下服务:   (1)Oracle SID VSS Writer ...

  5. 关于JS变量和作用域

    ECMAScript 变量:1.基本类型值(简单数据段) 2.引用类型值(可能由过个值构成的对象) → 保存在内存中的对象 动态属性: 只能给引用型值动态添加新属性,以便将来使用. 复制变量值 : 基 ...

  6. jquery 鼠标右键事件、左键单击事件判定

    $(function(){ $('a').mousedown(function(e){ alert(e.which) // 1 = 鼠标左键 left; 2 = 鼠标中键; 3 = 鼠标右键 retu ...

  7. zeromq-python使用

    安装参考saltstack编译安装.note 官方使用文档: http://zguide.zeromq.org/page:all 中文翻译文档: http://iyuan.iteye.com/blog ...

  8. UVA 712 S-Trees

    二叉树? 怒水~~ 注意一下查询与x值的对应关系就好~ #include <iostream> #include <cstring> #include <cstdio&g ...

  9. SQL Server 的各种查询和要申请的锁

    前期准备: 1.建表 create table T_Btree(X int primary key,Y nvarchar(4000));            create table T_Heap( ...

  10. 28 个 Unix/Linux 的命令行神器

    28 个 Unix/Linux 的命令行神器   下面是Kristóf Kovács收集的28个Unix/Linux下的28个命令行下的工具(原文链接),有一些是大家熟悉的,有一些是非常有用的,有一些 ...