時間搓格式化
select id,name,FROM_UNIXTIME(time,'%Y-%m-%d %H:%i:%s') as addtime from testtable where totaltime != '';
//time是時間戳字段,查出來之后是格式化的數據 ,重命名為 addtime
查詢的時候可以把時間格式變成時間戳
select id,name,UNIX_TIMESTAMP(time) as addtime from testtable1; //我的數據庫存的time格式是這樣的 :2019-02-27
每次用的時候,找也找不到,還是保存到自己的隨筆中。。。
來源:https://www.cnblogs.com/xbxxf/p/11114426.html
mysql 獲取時間搓,和轉換
sql:SELECT unix_timestamp(now());
結果:1506669159
獲得的時間戳為秒
格式化當前時間
sql:SELECT FROM_UNIXTIME(unix_timestamp(now()), '%Y-%m-%d %H:%i:%S');
結果:2017-09-29 15:15:29
原文鏈接:https://blog.csdn.net/lyg_come_on/article/details/78134083
獲取當前系統時間
1.獲取當前日期+時間
now();
sysdate();
這兩個函數都是獲取日期+時間,不同之處在於:now()在執行開始時值就得到了,sysdate()在函數執行時動態得到值
2.獲取當前日期:
curdate();
current_date();
current_date;
3.獲取當前時間:
curtime();
current_time();
current_time;
4.獲取UTC時間
A.獲取UTC日期:utc_date();
B.獲取UTC時間:utc_time();
C.獲取UTC日期+時間:utc_timestamp;
