Add minutes to my existing date iOS swift

  Problem:

I had one date with me.I want to add some minutes to the date and get the new date.

Solution:

extension Date {

    func addminutes(minsToAdd: Int) -> Date {

        let secondsInHours: TimeInterval = Double(minsToAdd) * 60

        let dateWithHoursAdded: Date = self.addingTimeInterval(secondsInHours)

        //Return Result

        return dateWithHoursAdded

    }}



Call the above function as like below.


let newDate = yourdate.addminutes(10)



newDate will store the new date after appending 10 minutes.

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