[스위프트3] String To Date or Date To String
1. String to Date
2. Date to String
1
2
3
4
5
6
7
8
|
static func String_To_Date(date:String, format:String) -> Date{
let paramFormat:DateFormatter = DateFormatter()
paramFormat.dateFormat = format
paramFormat.locale = Locale(identifier: "ko_KR")
let convertDate = paramFormat.date(from: date)! as Date
return convertDate
}
| cs |
2. Date to String
1
2
3
4
5
6
7
|
static func Date_To_String(date:Date, format:String) -> String{
let paramFormat:DateFormatter = DateFormatter()
paramFormat.dateFormat = format
paramFormat.locale = Locale(identifier: "ko_KR")
return paramFormat.string(from: date)
}
| cs |
댓글
댓글 쓰기