title: How to convert date picker value into String in swift 3.0?
body: <p>How to convert date picker value into String type in Swift 3.0 ? </p>
  
  <p>Right now I have managed to create date picker but the value that appear in textfield is today's date which is <strong>2/8/17, m/d/yy</strong> format.</p>
  
  <p>My goal is to convert <strong>m/d/yy</strong> into <strong>String</strong> and the date value will be <strong>2017-02-08, yyyy/mm/dd</strong> format </p>
  
  <p>The code as below.</p>
  
  <p><strong>Date.swift</strong></p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet var dateTxt: UITextField!
  
      let datepicker = UIDatePicker()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          displayDate()
      }
  
      func displayDate(){
          let toolbar = UIToolbar()
          toolbar.sizeToFit()
  
          let doneBtn = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector(donePick))
          toolbar.setItems([doneBtn], animated: false)
  
          dateTxt.inputAccessoryView = toolbar
  
          dateTxt.inputView = datepicker
      }
  
      func donePick(){
  
          let dateFormatter = DateFormatter()
          dateFormatter.dateStyle = .short
          dateFormatter.timeStyle = .none
  
          dateTxt.text = dateFormatter.string(from: datepicker.date)
          self.view.endEditing(true)
      }
  }
  </code></pre>
  
  <p>Can anyone help ? </p>
  
  <p>Thanks.</p>