Postgres时间戳:点后面的数字是什么?如何删除它? [英] Postgres timestamp: what is the number after the dot and how to remove it?
本文介绍了Postgres时间戳:点后面的数字是什么?如何删除它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用PHP将新记录插入到我的Postgres数据库。
在我的查询中,我添加了函数now()
来写入插入的日期和时间。
$query = "INSERT INTO myTable(field1, field2, date, field4, field5) values('" . pg_escape_string($value1) . "', '" . (int) pg_escape_string($value2) . "', NOW(), '" . pg_escape_string($value4) . "', '" . pg_escape_string($value5) . "')";
日期单元格的类型为timestamp without time zone
,其写入日期的方式如下:
2015-05-26 11:13:51.727018
点后数字是什么以及如何避免它?
谢谢。
推荐答案
那些是微秒。将其定义为timestamp(0) without time zone
。
time
、timestamp
和interval
接受可选的精确值p
,该值指定秒字段中保留的小数位数。默认情况下,精度没有显式限制。对于timestamp
和interval
类型,p
的允许范围是0到6。
引用:
- http://www.postgresql.org/docs/9.4/static/datatype-datetime.html
- http://www.postgresql.org/docs/9.4/static/sql-altertable.html
这篇关于Postgres时间戳:点后面的数字是什么?如何删除它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文