Code :
print("Getting previous date") var yourPrevDay = 5 // Your desired day var d = new Date(new Date().setDate(new Date().getDate()- yourPrevDay)) print(d)
Result :
Getting previous date Thu May 31 2018 05:20:06 GMT+0200 (CEST)
print("Getting previous date") var yourPrevDay = 5 // Your desired day var d = new Date(new Date().setDate(new Date().getDate()- yourPrevDay)) print(d)
Getting previous date Thu May 31 2018 05:20:06 GMT+0200 (CEST)