Created
April 30, 2019 15:25
-
-
Save kvabapo/08c596ca24d698d9db1af4413ec83ae0 to your computer and use it in GitHub Desktop.
Setting a date in JS
This file contains hidden or 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
| const someDate = new Date(); | |
| const numberOfDaysToAdd = 1; | |
| someDate.setDate(someDate.getDate() + numberOfDaysToAdd); | |
| const dd = someDate.getDate(); | |
| const mm = someDate.getMonth() + 1; | |
| const y = someDate.getFullYear(); | |
| const someFormattedDate = dd + '/'+ mm + '/'+ y; | |
| console.log(someFormattedDate); | |
| document.getElementById("datePicker").value = someFormattedDate; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment