title: Can you use a Swift DateFormatter to take a Date object, format it, and return it as a Date object?
body: <p>I'm trying to format a <code>Date</code> object in Swift using <code>DateFormatter</code>. I'm grabbing a Date object from a UIDatePicker in the format 2020-09-04T10:19:26+0000, and I want to reformat it to 2020-09-04 10:19.</p>
  <p>From what I understand, <code>DateFormatter</code> can only create a Date object from a string using the <code>date(from: String)</code> method, or a string from a Date object using <code>string(from: Date)</code>. Thus, for my seemingly simple use case, I would need two DateFormatters: One for converting my original date to a string, and a second one to format that string to my desired format and returning it as a Date object.</p>
  <p>Is this really the &quot;smart&quot; way to re-format a Date object in Swift, or am I missing something?</p>
  <p>edit:</p>
  <p>I'm saving projects (which can have a due date) to a database. Later on, I plan on reading specific projects from the db based on their due date. The UIDatePicker returns an unformatted Date object (with seconds, offset and so on), but I only need the date, hour and minutes (exact to a 15 minute interval).</p>