Last active
September 25, 2022 21:21
-
-
Save javierd79/0af7b7bf58215a2898e9ccf4a5d69f33 to your computer and use it in GitHub Desktop.
Snippet to get one day of the week every week in React.Js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const everyWeek = (x) => { | |
let prev = new Date(); | |
prev.setDate(prev.getDate() + (x+(7+prev.getDay())) % 7); | |
return prev | |
.toISOString() | |
.slice(0, 10) | |
.replace('T',' '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment