티스토리 뷰

반응형

 

날짜 차이 구하기

        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

반응형
댓글
300x250
반응형
최근에 올라온 글
최근에 달린 댓글
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Total
Today
Yesterday