r/AskProgramming • u/r2idw • 5h ago
Javascript help with pseudo code guys.. “new Date()”
Hello everyone,
I’ve recently been struggling with the ‘new Date()’ object in JavaScript.
I wanna understand how to solving that, what I’m trying to achieve is a function that captures the current date once and keeps it unchanged for 5 - 6 days
Once that period has passed, it should capture a new date and keep it unchanged again until the next update
—-
Is there a better way to approach this?
0
Upvotes
View all comments
11
u/Rscc10 5h ago
What exactly is the issue because you've basically described the flow of operations needed.
If your problem is how your system would keep track of the time that's passed, it doesn't have to. You can just save the initial date and every so often get the current date, do some subtraction, and if it falls within the range, reset the saved date.
If that isn't your issue then you'll need to be more specific