Get last week day of the date - Node.js Date

Node.js examples for Date:Week

Description

Get last week day of the date

Demo Code

/**/* w w  w .  j  a  va2  s  . c om*/
 * Get last week day of the date
 * @param  {integer} day
 * @return {date}
 */
Date.prototype.getLastWeekday = function(day)
{
    day = day || 1;

    var d = this.clone();
    while (d.getDay() != day)
    {
        d.addDays(-1);
    }
    d.clearTime();
    return d;
};

Related Tutorials