I have a big problem, I need to store the date and time selected by the user so that I can generate the notifications at the correct time. The date and time is captured by a date picker and when I get it as String it comes in the correct way "Sep 27 2016 13:04", but when I do the conversion to NSDate the time is zapped, 2016-09-27 16 : 04. Can anyone help solve this problem? I'm doing the tests with the iPhone and not on the simulator
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd MMM yyyy HH:mm"
dateFormatter.locale = NSLocale.currentLocale()
dateFormatter.timeZone = NSTimeZone.localTimeZone()
let date2:NSDate!
date2 = dateFormatter.dateFromString(dateStr4)
dateFormatter.dateFormat = "dd/MM/yyyy HH:mm"
if let unwrappedDate = date2 {
print(dateFormatter.stringFromDate(unwrappedDate))// aqui aparece a data e hora de maneira correta 27/09/2016 13:09
print("--->",unwrappedDate) // aqui a hora já fica zoada 27/09/2016 16:09
criaNotificacoes(unwrappedDate, comIntervalo: util.valorIntervalo(campoIntervalo.text!), totalDias: util.valorTempoDias(campoPeriodo.text!))
}else{
print("tratar erro ")
}