简体   繁体   English

如何使用 Supabase-JS 客户端插入没有时区的时间戳?

[英]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.

相关问题 使用 supabase-js 计算每个帖子的总喜欢数 - count totalLikes per post with supabase-js 如何使用客户端时区在客户端中输出数据库时间戳作为日期戳? - How to output a db timestamp as a date stamp in the client using the clients timezone? 如何使用 moment.js 从时间戳中获取时区名称? - How can i get the timezone name from timestamp using moment.js? 没有时区的PostgreSQL字段时间戳-如何检查它是否等于今天 - PostgreSQL field timestamp without timezone - how to check if it equals today 如何在不影响本机时区的情况下使用时间戳对数组进行排序 - How to sort an array with timestamp without affecting timezone in react native 如何通过使用javascript在Postgis时间戳中插入当前时间戳而没有时区列? - How to insert current timestamp in Postgis timestamp without time zone column by using javascript? 如何防止moment js根据服务器时区转换时间戳 - How to prevent moment js to covert the timestamp based on the server timezone 如何在没有moment-timezone.js的情况下获取时区 - How to get timezone without moment-timezone.js 如何猜测时间戳的时区? - How to guess the timezone of a timestamp? 如何在Moment JS中将时区时间戳转换为带有时区的datetime? - How to convert epoch timestamp to datetime with timezone in moment js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM