var dateComponents: DateComponents = (Calendar.current as NSCalendar).components([NSCalendar.Unit.day, NSCalendar.Unit.month, NSCalendar.Unit.year, NSCalendar.Unit.hour, NSCalendar.Unit.minute, NSCalendar.Unit.second], from: dateToFix)
dateComponents.hour = 11
dateComponents.minute = 58
dateComponents.second = 00
let fixedDate: Date = Calendar.current.date(from: dateComponents)!
print(fixedDate)
let formatter = DateFormatter()
formatter.dateStyle = DateFormatter.Style.long
formatter.timeStyle = DateFormatter.Style.medium
formatter.dateFormat = "yyyy-MM-dd h:mm a"
let dateString = formatter.string(from: fixedDate)
print(dateString)
我的输出:2017-07-26 11:58 AM但我希望2017-07-26 11:58 PM