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 Table5 Replies
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.Yes. sure!
ive Moved both the conversations to #support-community
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 😅 )
Google Cloud
Adding data  | Firestore  | Google Cloud
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
so the schema for this will be number is it ?