Please anyone share the code to find the previous week's first date from current date in JavaScript. For example, if the current date is 19th dec 2012, I should get 10th Dec 2012 and last date 16th Dec 2012 as result.
            Asked
            
        
        
            Active
            
        
            Viewed 942 times
        
    -1
            
            
        - 
                    1Who says a week starts on Monday? – Ash Burlaczenko Dec 19 '12 at 12:09
 - 
                    i want to monday to sunday get previous week. – crickpatel0024 Dec 19 '12 at 12:10
 - 
                    2it seems like it has already been answered several times on this site. http://stackoverflow.com/questions/5210376/get-first-and-last-day-of-the-week-in-javascript – Boundless Dec 19 '12 at 12:11
 
1 Answers
1
            
            
        function getPreviousSunday()
{
var today=new Date();
return new Date().setDate(today.getDate()-today.getDay()-7);
}
function getPreviousMonday()
{
var today=new Date();
if(today.getDay() != 0)
  return new Date().setDate(today.getDate()-7-6);
else
  return new Date().setDate(today.getDate()-today.getDay()-6);
}
        Nipun Jain
        
- 626
 - 4
 - 6