我尝试使用 PostgreSQL timestamp
数据类型,但它抛出错误
ERROR: date/time field value out of range: "1489849402536"
架构
create table times (
time timestamp not null,
);
JS代码
`insert into times(time) values (${Date.now()})`
附言另一种选择是使用 bigint
但这似乎有点矫枉过正。
最佳答案
使用 to_timestamp()
postgres function :
`insert into times (time) values (to_timestamp(${Date.now()} / 1000.0))`
关于javascript - 如何在 PostgreSQL 中保存 JS Date.now()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42876071/