A, MySQL date and time stamp conversion
1. The date stamp turn select UNIX_TIMESTAMP ( '2018-12-25 12:25:00') ; Results: 1545711900 Timestamp transfer date: FROM_UNIXTIME (unix_timestamp) --unix_timestamp timestamp select FROM_UNIXTIME (1545711900); Results : 2018-12-25 12:25:00 3. the date stamp transfer, custom return date format: FROM_UNIXTIME (unix_timestamp, format) - format , please refer to the latter theme select FROM_UNIXTIME (1545711900, '% Y- % m- T% D% '); - results: 2018-12-25 12:25:00
Two, DATE_FORMAT (date, format) function is used to display the date / time data in different formats
- The date argument is legitimate date. format output format predetermined date / time
- Format can be used are
Example:
select DATE_FORMAT(NOW(), '%Y-%m-%d %T');
Results: 2018-12-25 12:25:00
Example:
select DATE_FORMAT(NOW(), '%Y-%m-%d %T');
结果:2018-12-25 12:25:00