Home >Database >Mysql Tutorial >How to convert mysql date format to number format
How to convert mysql date format to digital format: 1. Check the date that needs to be converted; 2. By executing "SELECT DATE_FORMAT(Now(),'%Y%m%d%H%i%s' ) FROM test;" command can convert the date format into the digital format of YYYYMMDD.
The operating environment of this tutorial: Windows 10 system, mysql5.5 version, Dell G3 computer.
How to convert mysql date format to numeric format?
Convert the date format to the digital form of YYYYMMDD in mysql
SELECT DATE_FORMAT(Now(),'%Y%m%d%H%i%s') FROM test; %Y%m%d%H%i%s 年月日时分秒 %Y%m%d 对应 YYYYMMDD
Example:
Related extensions:
DATE_FORMAT() function is used to display date/time data in different formats.
Syntax
DATE_FORMAT(date,format)
The date parameter is a legal date. format specifies the date/time output format.
The formats that can be used are:
Format | Description |
---|---|
%a | Abbreviated week name |
%b | Abbreviated month name |
%c | Month, Value |
%D | Day of the month with English prefix |
%d | of the month Day, value (00-31) |
Day of the month, value (0-31) | |
Microseconds | |
hour(00-23) | |
hour(01-12) | |
hour(01-12) | |
Minute, value (00-59) | |
Day of the year (001-366) | |
hours(0-23) | |
hours(1-12) | |
Month name | |
Month, value (00-12) | |
AM or PM | |
Time, 12-hour (hh:mm:ss AM or PM ) | |
seconds (00-59) | |
seconds (00 -59) | |
Time, 24-hour (hh:mm:ss) | |
week(00-53) Sunday is the first day of the week | |
week(00-53) Monday is the first day of the week Day | |
Week (01-53) Sunday is the first day of the week, use | # with %X ##%v |
%W | |
%w | |
%X | |
%x | |
%Y | |
%y | |
The above is the detailed content of How to convert mysql date format to number format. For more information, please follow other related articles on the PHP Chinese website!