一、问题

  使用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)));

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2021-11-18
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2022-02-17
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案