MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/AskProgramming/comments/1yaxo1d/help_with_pseudo_code_guys_new_date/19tivti84se6a/?context=3
r/AskProgramming • u/r2idw • 2d ago
[removed] — view removed post
21 comments sorted by
View all comments
Show parent comment
2
Got it, sounds like local storage is what you're looking for.
Essentially, when you start your application, you'd check if there's a date stored in local storage. If there is, check if a week has passed since that date, and update it if so.
Have a read of this: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
You'll probably need to format the date as a string before trying to save it, but writing to local storage is as easy as:
localStorage.setItem('savedDate', dateString)
And reading it back:
let dateString = localStorage.getItem('savedDate')
View all comments
Show parent comment
2
u/GrainWeevil 2d ago edited 2d ago
Got it, sounds like local storage is what you're looking for.
Essentially, when you start your application, you'd check if there's a date stored in local storage. If there is, check if a week has passed since that date, and update it if so.
Have a read of this: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
You'll probably need to format the date as a string before trying to save it, but writing to local storage is as easy as:
localStorage.setItem('savedDate', dateString)And reading it back:
let dateString = localStorage.getItem('savedDate')