![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 nick ![]()
![]() |
[(NickName: "", UploadTime: "/Date(1505292562640)/", Account: "weiren", UploadType: "朋友", FileName: "02364444b0e042e5bda683a653ee765d"), (NickName: "", UploadTime: "/Date(1505292544457)/", Account: "weiren", UploadType: "朋友", FileName: "04e4d2cd51244caf9f40b127cfbe339b"), (NickName: "", UploadTime: "/Date(1505282582147)/", Account: "weiren", UploadType: "朋友", FileName: "06002d95766f4966a7c291b967edcf17"), (NickName: "", UploadTime: "/Date(1505282383737)/", Account: "weiren", UploadType: "朋友", FileName: "0bc2e178f48c472091a25afd2441e052"), (NickName: "", UploadTime: "/Date(1505786084793)/", Account: "weiren", UploadType: "朋友", FileName: "0caa976dac4647afa91071feb106f9c6"), (NickName: "", UploadTime: "/Date(1505291064337)/", Account: "weiren", UploadType: "朋友", FileName: "0d2c269eca6f4aef8b362bb2ce3aea55"), (NickName: "", UploadTime: "/Date(1505698299250)/", Account: "weiren", UploadType: "朋友", FileName: "1b3c89777e2045fca829203b04d1256d“)] ======================================================= func datetodate(date:String) -> String { var changedate = date.replacingOccurrences(of: "/Date(", with: "").replacingOccurrences(of: ")/", with: "") let index0 = changedate.startIndex let index10 = changedate.index(changedate.startIndex, offsetBy: 10) var time2 = changedate[index0..<index10] let timeStamp = time2 //轉換為時間 let timeInterval:TimeInterval = TimeInterval(timeStamp)! let date = NSDate(timeIntervalSince1970: timeInterval) let dateformatter = DateFormatter() dateformatter.dateFormat = "yyyy年MM月dd日 HH:mm:ss" //自定義的時間格式 let time = dateformatter.string(from: date as Date) print("對應時間:"+time) return time } 這串可以將UploadTime 轉成時間格式 ex: 2017年09月13日 16:49:22 ======================================================= 目前想要依照時間下去做排列 從日期最新的到日期最舊的 可以將data陣列重新排嗎 |