一、問題
使用PostgreSQL獲取當前系統時間戳。眾所周知,在MySQL中是這樣的:
select UNIX_TIMESTAMP(NOW())
二、解決方案
(1)精確到秒
select floor(extract(epoch from now())); 結果:"1574826646"
(2)精確到秒的小數
select extract(epoch from now());結果:"1574826646.79929"
(3)精確到毫秒:
select floor(extract(epoch from((current_timestamp - timestamp '1970-01-01 00:00:00')*1000)));
