반응형
// UTC 시간을 Locale 시간으로 변환
func utcToLocale(utcDate : String, dateFormat: String) -> String
{
	let dfFormat = DateFormatter()
	dfFormat.dateFormat = dateFormat
	dfFormat.timeZone = TimeZone(abbreviation: "UTC")
	let dtUtcDate = dfFormat.date(from: utcDate)
	
	dfFormat.timeZone = TimeZone.current
	dfFormat.dateFormat = dateFormat
	return dfFormat.string(from: dtUtcDate!)
}
    
// Locale 시간을 UTC 시간으로 변환
func localeToUtc(localeDate: String, dateFormat: String) -> String
{
	let dfFormat = DateFormatter()
	dfFormat.dateFormat = dateFormat
	dfFormat.timeZone = TimeZone.current
	let dtLocaleDate = dfFormat.date(from: localeDate)
	
	dfFormat.timeZone = TimeZone(abbreviation: "UTC")
	dfFormat.dateFormat = dateFormat
	return dfFormat.string(from: dtLocaleDate!)
}
반응형
블로그 이미지

SKY STORY

,