get-convex / convex-demos

Demo apps built on Convex.
https://docs.convex.dev/
165 stars 25 forks source link

What is the best practice to store date? #21

Closed mfakhrys closed 11 months ago

mfakhrys commented 11 months ago

Hello, What is the best practice to store date? I hope there is another data type for storing date.

nipunn1313 commented 11 months ago

Hi @mfakhrys - thanks for the question.

The supported Convex data types are listed here https://docs.convex.dev/database/types. There currently is not a first class date type. We may consider adding one at some point the future, so stay tuned. In the meantime, using a unix timestamp stored as a number works well.

The system field (https://docs.convex.dev/database/types#system-fields) of _creationTime uses this strategy, storing as a Float64 number of milliseconds since unix epoch.