func isExpired(time:String) -> Bool {
let dformatters = DateFormatter.init()
dformatters.dateFormat = "yyyy-MM-dd HH:mm"
let now = NSDate()
//let dateString1 = "2017-07-06 13:40"
let date1 = dformatters.date(from: time)
//let dateString2 = "2017-07-06 13:41"
//let date2 = dformatters.date(from: dateString2)
if date1?.compare(now as Date) == ComparisonResult.orderedAscending {
//print("date1 is earlier")
return false
} else if date1?.compare(now as Date) == ComparisonResult.orderedDescending {
//print("date2 is earlier")
return true
} else if date1?.compare(now as Date) == ComparisonResult.orderedSame {
//print("Same date!!!")
}
return true
}
//调用此方法,传入指定时间字符串,与当前时间对比,如果早于当前时间返回false,否则返回true