-4

I have a time picker in which the user picks the time and I am sending a notification to user ten minutes before or after the time user picked.Suppose if the user picks time as 11:00 AM then I want the notification to trigger at 10:55 AM. I am unable to subtract and add ten minutes to the time. As I am new to this Please help..I have spent a lot of time on it still not able to solve this. Any help is appreciated

2 Answers2

0

You could subtract minutes using the Calendar :

Calendar.current.date(byAdding: .minute, value: -10, to: yourDate)

Marwen Doukh
  • 1,946
  • 17
  • 26
0

Use Calendar of iOS.

let beforeThreeMinutes = Calendar.current.date(byAdding: .minute, value: -3, to: datePicker.date)

Sundeep Saluja
  • 1,089
  • 2
  • 14
  • 36