//得到当前时间
let date = Date.init()
let cal = Calendar.current
let unitFlags:NSCalendar.Unit = [NSCalendar.Unit.year,NSCalendar.Unit.month]
let conponent = (cal as NSCalendar).components(unitFlags,from: date)
print("当前年份是:\(conponent)年")
//得到当前时间
let date = Date.init()
let cal = Calendar.current
let unitFlags:NSCalendar.Unit = [NSCalendar.Unit.year,NSCalendar.Unit.month]
let conponent = (cal as NSCalendar).components(unitFlags,from: date)
print("当前年份是:\(conponent)年")