title: How to set local notification time to time on date picker for Swift
body: <pre><code>import UIKit
  import UserNotifications
  
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var myDatePicker1: UIDatePicker!
      @IBAction func action(_ sender: Any) {
          let content = UNMutableNotificationContent()
          content.title = "This is a notification"
          content.subtitle = "I hope this works"
          content.body = "from the tutorial"
          content.badge = 1
  
          let componentsFromDate = Calendar.current.dateComponents(in: TimeZone.current, from: myDatePicker1.date)
  
          let trigger = UNTimeIntervalNotificationTrigger(timeInterval: componentsFromDate, repeats: true)
  
          let request = UNNotificationRequest(identifier: "timeDone", content: content, trigger: trigger)
          UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
  
      }
  
  
      override func viewDidLoad() {
          super.viewDidLoad()
           UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge], completionHandler: {didAllow, error in})
          // Do any additional setup after loading the view, typically from a nib.
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  }
  </code></pre>
  
  <p>Here is what showed in the console when I printed the request and trigger: </p>
  
  <pre><code>&lt;UNNotificationRequest: 0x6000002335e0; identifier: timeDone, content:
   &lt;UNNotificationContent: 0x600000113ef0; title: This is a notification,
   subtitle: I hope this works, body: from the tutorial,
   categoryIdentifier: , launchImageName: , peopleIdentifiers: ( ),
   threadIdentifier: , attachments: ( ), badge: 1, sound: (null),
   hasDefaultAction: YES, defaultActionTitle: (null),
   shouldAddToNotificationsList: YES,
   shouldAlwaysAlertWhileAppIsForeground: NO, shouldLockDevice: NO,
   shouldPauseMedia: NO, isSnoozeable: NO, fromSnooze: NO,
   darwinNotificationName: (null), darwinSnoozedNotificationName: (null),
   trigger: &lt;UNCalendarNotificationTrigger: 0x600000233540;
   dateComponents: &lt;NSDateComponents: 0x6000003461a0&gt;
       Calendar: &lt;CFCalendar 0x60000009c7a0 [0x10c9fee40]&gt;{identifier = 'gregorian'}
       TimeZone: America/Vancouver (PDT) offset -25200 (Daylight)
       Era: 1
       Calendar Year: 2017
       Month: 8
       Leap month: no
       Day: 11
       Hour: 9
       Minute: 58
       Second: 39
       Nanosecond: 0
       Quarter: 0
       Year for Week of Year: 2017
       Week of Year: 32
       Week of Month: 2
       Weekday: 6
       Weekday Ordinal: 2, repeats: YES&gt;&gt;
  </code></pre>
  
  <p>I am new to app development with Swift and am trying to create a simple app that sends the user a local notification when at the time they select on a date picker. For some reason, the <code>UNCalenderNotificationTrigger</code> will only take <code>DateComponents()</code> and <code>DateComponents()</code> must be an Int, and not a type <code>Date()</code> (from the date picker). Could someone please help me? Thanks </p>