ashuvssut (ashu)
ashuvssut (ashu)•2y ago

Get server time in a query/mutation for `updatedAt`

Hi, is there any server function to get the server time in my query/mutation I want to create a updatedAt column in a Table
5 Replies
ballingt
ballingt•2y ago
You can use Date.now() to get milliseconds since epoch, which works just like you'd expect in mutations. I guess I should move these to #support-community, @ashuvssut (ashu) if you could ask great questions like this where others might be interested in finding the answer later to #support-community that's be helpful.
ashuvssut (ashu)
ashuvssut (ashu)OP•2y ago
Yes. sure! ive Moved both the conversations to #support-community
ashuvssut (ashu)
ashuvssut (ashu)OP•2y ago
I read it somewhere that BaaS providers like FIrebase have functions like serverTimestamp() 2 possible reasons:- - When updating multiple timestamp fields inside of a transaction, each field receives the same server timestamp value. - maybe 2 VMs might now have the same exact Time? ( I dont know if any of these applies to convex 😅 )
ballingt
ballingt•2y ago
Indeed you'll get the same time each time you ask within a single execution of a mutation. which should work well for a modifiedAt field This Date.now() call is implemented specifically for the Convex runtime, so we're providing the behavior we think is useful with it
ibrahimyaacob
ibrahimyaacob•12mo ago
so the schema for this will be number is it ?

Did you find this page helpful?