title: How to get previous and next month in calendar-Swift
body: <p>I am trying to get previous and next month by click on button but this has changed my year, not month.</p>
  <p>I am trying it from using <a href="https://stackoverflow.com/questions/13410109/how-do-i-implement-previous-next-month-buttons-and-show-dates-for-current-month">this answer</a> but it is in Objective-C.</p>
  <pre><code>func firstDateOfMonth() {
      let components = calendar.components([.Year, .Month], fromDate: date)
      let startOfMonth = calendar.dateFromComponents(components)!
      print(dateFormatatter.stringFromDate(startOfMonth)) // 2015-11-01
  }
  
  func lastDateOfMonth() {
      let components = calendar.components([.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: date)
      
      let month = components.month
      let year = components.year
      
      let startOfMonth1 = (&quot;01-\(month)-\(year)&quot;)
      
      var startOfMonth : NSDate?
      var lengthOfMonth : NSTimeInterval = 0
      calendar.rangeOfUnit(.Month, startDate: &amp;startOfMonth, interval: &amp;lengthOfMonth, forDate: date)
      let endOfMonth = startOfMonth!.dateByAddingTimeInterval(lengthOfMonth - 1)
      print(dateFormatatter.stringFromDate(endOfMonth))
  }
  
  func monthCalculation() {
      firstDateOfMonth()
      lastDateOfMonth()
  }
  
  @IBAction func previousMonthBtnAction(sender: AnyObject) {
      let componen = calendar.components([.Day , .Month , .Year], fromDate: date)
      componen.month = -1
      self.date = calendar.dateFromComponents(componen)!
      print(self.date)
  }
  
  @IBAction func nextMonthBtnAction(sender: AnyObject) {
  
  }
  </code></pre>
  <p>So how to do it for both previous and next month?</p>