title: NSDateFormatter to Int in Swift
body: <p>I am trying to convert a NSDateFormater Int, but the variables return nil. 
  This is the code I'm using:   </p>
  
  <pre><code>    var datePeriodBegin:NSDate = NSDate()    
      if(NSUserDefaults.standardUserDefaults().objectForKey("datePeriodBegin") != nil){
          datePeriodBegin = (NSUserDefaults.standardUserDefaults().objectForKey("datePeriodBegin")! as? NSDate)!
      }
  
      let datePeriodEnd = NSCalendar.currentCalendar().dateByAddingUnit(NSCalendarUnit.CalendarUnitMonth, value: 6, toDate: datePeriodBegin, options: nil)!
  
  
      var dateFormatter: NSDateFormatter = NSDateFormatter()
      dateFormatter.dateFormat = "yyyyMMdd000000"
  
      var start:Int = dateFormatter.stringFromDate(datePeriodBegin).toInt()!
      var end:Int = dateFormatter.stringFromDate(datePeriodEnd).toInt()!
  
      println(start) // return nil in iPhone 4S -&gt; iPhone 5s
  </code></pre>