如何将JS Date.now()保存到PostgreSQL中?

8 浏览
0 Comments

如何将JS Date.now()保存到PostgreSQL中?

我尝试使用PostgreSQL的timestamp数据类型,但是它抛出了一个错误:ERROR: date/time字段值超出范围:"1489849402536"

数据库模式如下:

create table times (
  time   timestamp    not null,
);

JavaScript代码如下:

`insert into times(time) values (${Date.now()})`

P.S. 另一种选择是使用bigint,但这似乎有点过度设计。

0