This article shares an article on mysql date formatting implementation. This article mainly introduces some references for date_format () functions and their usage in cmd mode, in fact, it is the same in cmd and php. If you need it, you can refer to it.
This article shares an article on mysql date formatting implementation. This article mainly introduces some references for date_format () functions and their usage in cmd mode, in fact, it is the same in cmd and php. If you need it, you can refer to it.
Directly in command mode
Date Formatting Function date_format ()
The Code is as follows: |
|
> Date_format (now (), '% y '); + ------------------------- + | Date_format (now (), '% y') | + ------------------------- + | 1, 2009 | + ------------------------- + 1 row in set (0.00 sec) Extended: % Y: Year % c: month % d: day % H: hour % I: minute % s: Second Mysql> select date_format (now (), '% Y-% c-% d % h: % I: % s'); + ------------------------------------------ + | Date_format (now (), '% Y-% c-% d % h: % I: % s') | + ---------------------------------------- + | 06:59:40 | + ---------------------------------------- + 1 row in set (0.00 sec )--- |
About date_format Functions
DATE_FORMAT (date, format)
Format the date value based on the format string. The following modifier can be used in the format string: % M month name (January ...... December)
% W name of the Week (Sunday ...... Saturday)
% D indicates the date of the month with an English prefix (1st, 2nd, 3rd, and so on .)
% Y year, number, 4 digits
% Y year, number, 2 digits
% A abbreviated name of the Week (Sun ...... Sat)
% D number of days in the month (00 ...... 31)
% E number of days in the month (0 ...... 31)
% M month, number (01 ...... 12)
% C month, number (1 ...... 12)
% B abbreviated month name (Jan ...... Dec)
% J days in a year (001 ...... 366)
% H hour (00 ...... 23)
% K hour (0 ...... 23)
% H hour (01 ...... 12)
% I hour (01 ...... 12)
% L hour (1 ...... 12)
% I minute, number (00 ...... 59)
% R time, 12 hours (hh: mm: ss [AP] M)
% T time, 24 hours (hh: mm: ss)
% S seconds (00 ...... 59)
% S seconds (00 ...... 59)
% P AM or PM
% W days in a week (0 = Sunday ...... 6 = Saturday)
% U Week (0 ...... 52). Sunday is the first day of the week.
% U Week (0 ...... 52) Monday is the first day of the week.
% A text "% ".
% A-the day of the week
% A-full writing of the day of the week
% B-abbreviated month
% B-full write of the month
% C-Date and Time 06/12/05 11:15:10
% C-century time
% D-number of the month (from 01 to 31)
% D-same as % m/% d/% y
% E-the number of months. If it is a singular number, add a space (from 1 to 31) to the front)
% G-century
% G-century [century, 9999]
% H-same as % B
% H-24 hours (from 00 to 23)
% I-12 hours (from 01 to 12)
% J-the day of the year (from 001 to 366)
% K-24 hours, with a space in front of a single number (from 0 to 23)
% L-12 hours, with a space in front of a single number. (range 1 to 12)
% M-month (range 01 to 12)
% M-minute
% N-linefeed
% P-display 'am' or 'pm 'in the morning or afternoon'
% R-a.m. Or p. m. Format time
% R-24 hour time
% S-second
% T-tab
% T-same as % H: % M: % S
% U-[] indicates the day of the week
% U-computing is the week of the year. It starts from the first Sunday of the year.
% V-calculate the week of the year, from 01 to 53. The first week must have at least four days in the year, and Sunday is the first day of the week.
% W-represents the day of the week in the form of a number, and Sunday is 0
% W-the week of the year in the form of digits, starting from the first Monday of the year
% X-display Date: Month/day/year
% X-display time: hour: minute: Second
% Y-not including the Year of the Century
% Y-Year of the Century
% Z-Time Zone
%-Output %