Compare date contains today date not to compare with time iOS swift
Solution:
In date function it will not be able to check that if your date contains today date.So you can try with datecomponents to compare your date contains to the today date not the time.
Code:
In date function it will not be able to check that if your date contains today date.So you can try with datecomponents to compare your date contains to the today date not the time.
Code:
let cal = Calendar.init(identifier: Calendar.current.identifier)
let isToday = cal.isDateInToday(yourdate as! Date)
if isToday {
print("date contains today")
} else {
print("date not contains today")
}
Comments
Post a Comment