MySQL時間戳和時間的獲取/相互轉換/格式化
阿新 • • 發佈:2018-12-13
獲取當前時間戳
select unix_timestamp();
- 1
同
select unix_timestamp(now());
- 1
獲取當前時間
select now();
- 1
時間轉時間戳
select unix_timestamp('2018-01-15 09:45:16');
- 1
時間戳轉時間
select from_unixtime(1515980716);
- 1
時間戳格式化
SELECT from_unixtime(1515980716, '%Y-%m-%d %H:%i:%S' );
- 1
時間格式化
select date_format(now(), '%Y-%m-%d');
select date_format('2018-01-15 09:45:16', '%Y-%m-%d');
- 1
- 2
視覺化轉換
http://tool.chinaz.com/Tools/unixtime.aspx