Home Database Mysql Tutorial 关于mysql数据库格式化简单介绍

关于mysql数据库格式化简单介绍

Jun 07, 2016 pm 04:16 PM
mysql introduce about database format Simple

DATE_FORMA T(date, format) 根据格式串format 格式化日期或日期和时间值date,返回结果串。 可用DATE_FORMAT( ) 来格式化DATE 或DATETIME 值,以便得到所希望的格式。根据format字符串格式化date值: %S, %s 两位数字形式的秒( 00,01, . . ., 59) %i 两位数

  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

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

How to optimize MySQL query performance in PHP?

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

How to use MySQL backup and restore in PHP?

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into a MySQL table using PHP?

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

How to use MySQL stored procedures in PHP?

Detailed introduction of Samsung S24ai functions Detailed introduction of Samsung S24ai functions Jun 24, 2024 am 11:18 AM

Detailed introduction of Samsung S24ai functions

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

Detailed tutorial on establishing a database connection using MySQLi in PHP

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

How to create a MySQL table using PHP?

See all articles