Swift中Date类的格式化输入输出 Posted on 2016-11-18 | In Swift | | Visitors 将Date类的时间格式化输入输出 123456789101112131415161718let start = "2016-09-28"// Input formatlet dateFormatter = DateFormatter()dateFormatter.dateFormat = "yyyy-MM-dd"let startDate:Date = dateFormatter.date(from: start)!let endDate:Date = Date.init() // current date// Output formatlet fmt = DateFormatter()fmt.dateFormat = "yyMMdd"var date = startDate // first datewhile date <= endDate { date.addTimeInterval(60*60*24) // add a day print(fmt.string(from: date)}