Reference Link: https://www.cnblogs.com/jhy-ocean/p/5560857.html
MySQL timestamp involves a function
Date_format (date, format) function, MySQL date format function date_format ()
Unix_timestamp () function
Str_to_date (str, format) function
From_unixtime (unix_timestamp, format) function, MySQL timestamp format function from_unixtime
Time-to-round string
Select ' %y-%m-%d ' ); #结果:--
Time-to-time stamping
Select Unix_timestamp (now ()); #结果:1452001082
String Turn time
Select str_to_date ('2016-01-02'%y-%m-%d%H') ; #结果: $-xx:xx
String Turn timestamp
Select unix_timestamp ('2016-01-02'); #结果:1451664000
Time Stamp Turn time
Select from_unixtime (1451997924); #结果:-£º
Timestamp to String
Select from_unixtime (1451997924,'%y-%d'); Result: $-A-V:
Schedule
MySQL date formatting (format) range of values.
|
value |
meaning |
Seconds |
%s,%s |
Two digits in the form of seconds (00, 01, ..., 59) |
Score of |
%I,%I |
Two digits in the form of points (00, 01, ..., 59) |
Hours |
%H |
24-hour system, two-digit hour (00,01, ..., 23) |
%h |
12-hour system, two-digit hour (00,01, ..., 12) |
%k |
24-hour system, number of forms hours (0,1, ..., 23) |
%l |
12-hour system, number of forms hours (0,1, ..., 12) |
%T |
24-hour system, time form (HH:MM:SS) |
%r |
12-hour, time form (Hh:mm:ss AM or PM) |
%p |
Am Morning or PM afternoon |
Week |
%W |
The name of each day of the week (Sunday,monday, ..., Saturday) |
%a |
Abbreviation for the name of each day of the week (Sun,mon, ..., Sat) |
%w |
Identify weeks (0=sunday,1=monday, ..., 6=saturday) in digital form |
%u |
The number represents the week, and Sunday is the first day of the week |
%u |
The number represents the week, and Monday is the first day of the week |
Days |
%d |
Two-digit number of days in the month (01,02, ..., 31) |
%e |
Number indicates the number of days in the month (1, 2, ..., 31) |
%d |
The English suffix indicates the number of days in the month (1st,2nd,3rd ... ) |
%j |
Three-digit number of days in the year (001,002, ..., 366) |
Month |
%M |
English month name (January,february, ..., December) |
%b |
English abbreviation month name (Jan,feb, ..., DEC) |
%m |
Two digits indicate month (01,02, ..., 12) |
%c |
Numbers indicate the month (1, 2, ..., 12) |
Years |
%Y |
Four-digit year (2015,2016 ...) |
%y |
Two-digit year (15,16 ...) |
Text output |
% text |
Direct output of text content |
MySQL timestamp function