- now()
select now(); 结果:2021-04-23 14:29:50.043339+08
返回 年-月-日 时:分:秒.毫秒+时区
- current_timestamp效果是和now()一样的。
select current_timestamp; 结果:2021-04-23 14:32:28.865183+08
返回 年-月-日 时:分:秒.毫秒+时区
- current_date
返回 日期-年月日select current_date; 结果:2021-04-23
- current_time
select current_time; 结果:14:33:36.645919+08
返回 时间-时分秒毫秒+时区
-
时间格式转换
--timestamp(num) num表示毫秒保留数 select now()::timestamp(0)without time zone
-
获取系统当前时间毫秒数的sql,以及秒级时间戳
1、这个比较准确 select floor(extract(epoch from now())); 2、获取数据库中毫秒级 select floor(extract(epoch from((current_timestamp - timestamp '1970-01-01 00:00:00')*1000))); 3、获取系统中秒级的时间 select floor(extract(epoch from(current_timestamp - timestamp '1970-01-01 00:00:00')));
postgresql获取系统当前时间
最新推荐文章于 2023-07-24 18:04:51 发布