[英]How to insert timestamp without timezone using Supabase-JS client?
I want to insert current timestamp without timezone to Supabase.我想将没有时区的当前时间戳插入 Supabase。
I know I can set default value of the timestamp column to NOW()
but there can be some delay in the timing and I need it precise.我知道我可以将时间戳列的默认值设置为
NOW()
但时间可能会有一些延迟,我需要它精确。
I have tried Date.now()
but got the error: date/time field value out of range
我试过
Date.now()
但出现错误: date/time field value out of range
How can this be done?如何才能做到这一点?
You can insert the time from javascript by setting您可以通过设置从 javascript 插入时间
new Date().toISOString();
when doing an insert or update.在进行插入或更新时。 I want to address the first part of your statement though as the precise time is the time that data hits the server so having
NOW()
as the default value in Postgres is more accurate than you passing the date over the wire in my opinion.我想解决你声明的第一部分,因为精确时间是数据到达服务器的时间,所以在我看来,将
NOW()
作为 Postgres 中的默认值比通过网络传递日期更准确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.