JavaScript \ Get Date of Last Thursday -


how can date of last thursday via javascript?

if thursday today -7 days.

after format output '17 april 2016'.

var weekdays = [ "sun", "mon", "tue", "wed", "thurs", "fri", "sat" ];  function getdateforlastoccurence( strday ) {    var date = new date();    var index = weekdays.indexof(strday);    var difference =  date.getday() - index;     if (difference < 0 )     {       difference = -7 - difference;    }    date.setdate( date.getdate() + difference );    return  date; }  getdateforlastoccurence( "tue" ); getdateforlastoccurence( "thurs" ); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -