Skip to content

does Date.now() value is based on machine it runs on, or it works as nodejs it gives the value from epoch?? #14440

Closed Answered by vkarpov15
mhmadalaa asked this question in Q&A
Discussion options

You must be logged in to vote

default: Date.now() vs default: () => Date.now() or default: Date.now?

That's because default: Date.now() sets the default to the current value of Date.now(). So equivalent to Default: 1710793129346. Basically you're setting the default value to your server's start time.

With default: () => Date.now(), you're setting default to a function that Mongoose executes to get the default each time.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mhmadalaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants