title: How to send Date and Time separately to backend in swift?
body: <p><code>fromDateLabel.text</code> getting date and time from datepicker.. which i need to send date and time seperatedly to backend</p>
  <p>when i do <code>DateFormatter</code> date is coming correctly but i<strong>n time, only two digit values are working means time taking 10, 11, 12 O'Clocks. if i take 1,2,3,4,5 its not working</strong></p>
  <p><strong>code:</strong> here single digit time not working</p>
  <pre><code>    var fromDateArr = fromDateLabel.text!.components(separatedBy: &quot;,&quot;)
      fromDate = fromDateArr[0]
      fromTime = fromDateArr[1].replacingOccurrences(of: &quot; &quot;, with: &quot;&quot;)
  
          let inputFormatter = DateFormatter()
          inputFormatter.dateFormat = &quot;MM/dd/yy&quot;
          let showDateFrom = inputFormatter.date(from: fromDate)
          inputFormatter.dateFormat = &quot;dd-MM-yyyy&quot;
          formateFromdate = inputFormatter.string(from: showDateFrom!)
          print(&quot;formate from date \(formateFromdate)&quot;)
  </code></pre>
  <p><strong>if i formate date and time like below nothing works</strong></p>
  <pre><code>        let fromDate = fromDateLabel.text!
          let inputFormatter = DateFormatter()
          inputFormatter.dateFormat = &quot;MM/dd/yy, hh:mm:ssa&quot;
          guard  let showDateFrom = inputFormatter.date(from: fromDate) else { return }
  
          inputFormatter.dateFormat = &quot;MM/dd/yyyy&quot; // -&gt; to get date only
          formateFromdate = inputFormatter.string(from: showDateFrom)
          print(&quot;from date: &quot;, formateFromdate)
  
          inputFormatter.dateFormat = &quot;hh:mm a&quot; // -&gt; to get time only
          formateFromTime = inputFormatter.string(from: showDateFrom)
  
          print(&quot;from time&quot;)
  </code></pre>
  <p>How to send date and time separately to backend.. with 1 to 12hrs time</p>
  <p><strong>NOTE</strong>: if its 8 o clock then the out put time should be 08:15, not 8:15.. thats the issue.. please help me with code</p>