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
Post a Comment