I generate a NSDate object from string.
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = \"yyyy-MM-dd HH:mm:ss\"
dateFormatter.timeZone = NS
For Swift 3 you can use this function:
//get next date by adding hours func
getNewDateAfterAddingHours(hoursToAdd:NSInteger, oldDate:Date) -> Int64 {
let calendar = Calendar.current
let newDate = calendar.date(byAdding: .hour, value: hoursToAdd, to: oldDate)
return Int64((newDate?.timeIntervalSince1970)!)
}