Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let date = new Date() //Get today
- let transformDate = date.getDate() - 30 //Remove 30 days from today
- date.setDate(transformDate) //Set the current date to the removed days version variable
- console.log(`${date.getFullYear()}-${date.getMonth().toString().length == 1 ? '0' + (date.getMonth()+1) : date.getMonth()}-${date.getDate()}`) //Console logs the new format for sql
Add Comment
Please, Sign In to add comment