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:


                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

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift