PostgreSQL query the current time timestamp

First, the problem

  Using PostgreSQL to get the current system time stamp. As we all know, in MySQL like this:

   select UNIX_TIMESTAMP(NOW())

Second, the solution

(1) to the nearest second

  select floor(extract(epoch from now())); 结果:"1574826646"

 

(2) accurate to fractions of a second

  select extract(epoch from now());结果:"1574826646.79929"

 

(3) to the millisecond:

  select floor(extract(epoch from((current_timestamp - timestamp '1970-01-01 00:00:00')*1000)));

 

 

Guess you like

Origin www.cnblogs.com/songxingzhu/p/11941285.html