라이브 상세 - 날짜 포맷 yyyy년 MM월 dd일 (E) a hh시 mm분 로 수정
This commit is contained in:
@@ -14,11 +14,15 @@ extension Optional where Wrapped == String {
|
||||
}
|
||||
|
||||
extension String {
|
||||
func convertDateFormat(from: String, to: String) -> String {
|
||||
func convertDateFormat(from: String, to: String, locale: Locale? = nil) -> String {
|
||||
let fromFormatter = DateFormatter()
|
||||
fromFormatter.dateFormat = from
|
||||
fromFormatter.timeZone = TimeZone(identifier: TimeZone.current.identifier)
|
||||
|
||||
if let locale = locale {
|
||||
fromFormatter.locale = locale
|
||||
}
|
||||
|
||||
if let date = fromFormatter.date(from: self) {
|
||||
return date.convertDateFormat(dateFormat: to)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user