1. Time stamp transfer date

select FROM_UNIXTIME(1606028010.'%Y-%m-%d %H:%i:%s');
Copy the code

Two, date to time stamp

select unix_timestamp('the 2018-01-15 09:45:16');
Copy the code

Time stamp formatting

The ten-digit timestamp converts to a fixed format (YYYY-MM-DD HH: MM: SS) date

1. Format requirements

%M January...... December) %W Sunday... Saturday) %D Dates of months with English prefixes (1st, 2nd, 3rd, etc.) %Y year, number,4Bit %y year, number,2Bit %a abbreviated name of the week (Sun... Sat) %d Days in month, number (00...31) %e Days in the month, number (0...31) %m month, number (01...12) %c month, figure (1...12) %b Abbreviated month names (Jan... Dec) %j Number of days in a year (001...366) %H hours (00...23) %k hours (0...23) %h hours (01...12) %I hours (01...12) %l hours (1...12) % I minutes, number (00...59) %r time,12(hh:mm:ss [AP]M) %T24Hours (hh:mm:ss) %S seconds (00...59Seconds () % s00...59) %p AM or PM %w Days of the week (0= Sunday...6=Saturday) %U0...52Sunday is the first day of the week here.0...52), where Monday is the first day of the week %% a word "%".Copy the code
select FROM_UNIXTIME(1567267200.'%Y-%m-%d %H:%i:%s');
Copy the code

Four, date formatting

select DATE_FORMAT('the 2020-12-15 11:19:27'.'%Y-%m-%d');
Copy the code

Convert 13 – bit timestamp to 10 – bit timestamp

Mysql time stamps are 10 bits, so you can simply intercept the subscripts from 1 to 10 bits

select substr(1567267200000.1.10);
Copy the code

Vi. Current time

1. Obtain the current time

select now(a);
Copy the code

2. Get the current ten-digit timestamp

select unix_timestamp(now());
Copy the code

3. Get the previous three days

SELECT now(a) - interval 72 hour;
Copy the code