Tuesday, June 5, 2018

Get the Date of Previous Day in Javascript


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)

No comments:

Post a Comment