Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of converting mysql date into string

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor shares with you the method of converting mysql dates into strings. I believe many people do not know much about it. In order to let you know more about the methods of converting mysql dates into strings, I have summarized the following contents for you. Let's look down together. I'm sure you'll get something.

The method of converting mysql date to string

Mysql converts the date to a string

Select date_format (time,'% Y-%m-%d% HRV% iRO% s') from info # 2019-08-22 21:03:21

MySQL DATE_FORMAT () function

MySQL Date function

Definition and usage

The DATE_FORMAT () function is used to display date / time data in different formats.

Grammar

DATE_FORMAT (date,format)

The date parameter is a legal date. Format specifies the output format of the date / time.

The formats you can use are:

Format and description

% an abbreviated week name

% b abbreviated month name

% c month, numeric

% D day of the month with English prefix

Day of% d month, numeric (00-31)

Day of% e month, numeric (0-31)

% f microseconds

% H hours (00-23)

% h hours (01-12)

% I hours (01-12)

% I minutes, value (00-59)

Days of% j year (001-366)

% k hours (0-23)

% l hours (1-12)

% M month name

% m month, numeric (00-12)

% p AM or PM

% r time, 12-hour (hh:mm:ss AM or PM)

% s seconds (00-59)

% s seconds (00-59)

% T time, 24-hour (hh:mm:ss)

% U week (00-53) Sunday is the first day of the week

% u week (00-53) Monday is the first day of the week

% V week (01-53) Sunday is the first day of the week, used with% X

% v week (01-53) Monday is the first day of the week, used with% x

% W week name

% w days of the week (0 = Sunday, 6 = Saturday)

% X year, where Sunday is the first day of the week, 4 digits, used with% V

% x year, where Monday is the first day of the week, 4 digits, used with% v

% Y year, 4 digits

% y year, 2 digits

Example

The following script uses the DATE_FORMAT () function to display different formats. We use NOW () to get the current date / time:

DATE_FORMAT (NOW (),'% b% d% Y% HGV% I% p') DATE_FORMAT (NOW (),'% mmurf% dmurf% Y') DATE_FORMAT (NOW (),'% d% b% y') DATE_FORMAT (NOW (),'% d% b% Y% TVV% f')

The results are similar:

Dec 29 2008 11:45 PM12-29-200829 Dec 0829 Dec 2008 16 purl 25 purl 46.635

This is the end of the method of converting mysql dates into strings. I hope the above content can be of some reference value and can be put into practice. If you like this article, you might as well share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report