티스토리 뷰
반응형
날짜 차이 구하기
let myDateComponents = DateComponents(year: 2022, month: 3, day: 01)
let startDate = Calendar.current.date(from: myDateComponents)!
let offsetComps = Calendar.current.dateComponents([.year,.month,.day], from: startDate, to: Date())
if case let (y?, m?, d?) = (offsetComps.year, offsetComps.month, offsetComps.day) {
print("\(y)년 \(m)월 \(d)일 만큼 차이남")
}
TimeIntervalSinceNow
TimeInterval
Locale
Date
DateFormatter
Calendar
DateComponents
iOS
Swift
Xcode
DateCompare
Difference
반응형
'iOS Swift + UIKit' 카테고리의 다른 글
iOS Swift Email Masking (이메일 마스킹 * 표시 ID 아이디 가리기) (0) | 2022.06.01 |
---|---|
iOS Swift 웹뷰 html 바디 가져오기 (get webview html body tag) (0) | 2022.05.04 |
iOS Swift 앱 안끄고 언어 변경 ( 앱 내 언어 설정 ) (4) | 2021.04.05 |
iOS Swift 다국어 설정 - Code Localizing (0) | 2021.04.02 |
iOS Swift 다국어 설정 - Storyboard Localizing (0) | 2021.04.01 |
댓글