title: Set current date from datepicker on textfield
body: <p>I'm setting a datepicker on a textfield. For that this is what I've written..(in <code>viewDidLoad</code>)</p>
  
  <pre><code>    let datePicker = UIDatePicker()
      datePicker.datePickerMode = UIDatePickerMode.date
      datePicker.addTarget(self, action: #selector(AddDetailsViewController.theDatePickerValueChanged(sender:)), for: .valueChanged)
      dateTimeTextfield.inputView = datePicker
  </code></pre>
  
  <p>And outside <code>viewDidLoad</code> I have the function <code>theDatePickerValueChanged</code> given like so...</p>
  
  <pre><code>@objc func theDatePickerValueChanged(sender: UIDatePicker) {
      let formatter = DateFormatter()
      formatter.dateStyle = .medium
      formatter.timeStyle = .medium
      dateTimeTextfield.text = formatter.string(from: sender.date)
  }
  </code></pre>
  
  <p>But now what happens is when I tap on the textfield, the datePicker comes up. But if I want the current date to be set on the textfield, then I have to move forward or backward from the current date on the datePicker and then again return to that current date.</p>
  
  <p>But what I want is when the datePicker comes up, the current date on it should be directly set on the textfield without me requiring to go forward or backwards from the current date. How can I achieve this...? </p>