Created
April 25, 2018 14:42
-
-
Save jbarros35/0562bf47f162c4351d6f05b602203c7d to your computer and use it in GitHub Desktop.
Revisions
-
jbarros35 created this gist
Apr 25, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ // REMARK: format date for better display func convertDate(date: Date) -> String? { let dateFormatterGet = DateFormatter() dateFormatterGet.dateFormat = "yyyyMMdd HH:mm:ss" let dateString = dateFormatterGet.string(from: date) return dateString } // REMARK: server sends dates on JS string format func convertJSDate(date: String) -> String? { let dateFormatterGet = DateFormatter() dateFormatterGet.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" if let date = dateFormatterGet.date(from: date) { return convertDate(date: date) } return nil }