let date: NSDate = NSDate()
let cal: NSCalendar = NSCalendar(calendarIdentifier:NSCalendar.Identifier.gregorian)!
cal.timeZone = NSTimeZone.system
print(cal.timeZone)
let newDate: NSDate = cal.date(bySettingHour: 0, minute: 0, second: 0, of: date as Date, options: NSCalendar.Options())! as NSDate
let localNotification = UILocalNotification()
localNotification.fireDate = newDate as Date
localNotification.repeatInterval = NSCalendar.Unit.day
print(newDate)
localNotification.category = "First_Category"
localNotification.alertBody = "Hello from device"
localNotification.soundName = UILocalNotificationDefaultSoundName
localNotification.applicationIconBadgeNumber = UIApplication.shared.applicationIconBadgeNumber + 1
UIApplication.shared.scheduleLocalNotification(localNotification)
Here is my code to create a local notification. But I am not sure why the newDate will be slower than my current time. for example, Asia/Kuala_Lumpur (current) 2017-09-27 16:00:00 +0000 from the 2 print statements above. my current time is 2017-09-28 17:02:20.974. why slower than 1 day to my current time? if I set the hour to 9, it will be 1am in the morning and it is still slower than my current time. Also, I want to set every morning 9am.