Get the day of the current date last year using SetYear() in Javascript

var now = new Date()
var year = now.getYear()
now.setYear(year - 1)
ar = new Array(7)
ar[0] = " Sunday"
ar[1] = " Monday"
ar[2] = " Tuesday"
ar[3] = " Wednesday"
ar[4] = " Thursday"
ar[5] = " Fri day"
ar[6] = " Saturday"
document. write(" Last year, the current day was " + ar[now. getDay() ] )

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.