title: How to convert seconds to hh:mm:ss.millisecond format c++?
body: <p>I need to convert seconds in to hh:mm:ss.milliseconds and I need that this format must be respected. I mean that hours, minutes and seconds must have 2 digits and milliseconds 3 digits.
  For example, if seconds = 3907.1 I would to obtain 01:05:07.100</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;stdio.h&gt;
  #include &lt;sstream&gt;
  #include &lt;math.h&gt;
  using namespace std;
  
  int main()
  {   
      double sec_tot = 3907.1;
      double hour = sec_tot/3600; // seconds in hours
      double hour_int;
      double hour_fra = modf(hour, &amp;hour_int );//split integer and decimal part of hours
      double minutes = hour_fra*60; // dacimal hours in minutes
      double minutes_int;
      double minutes_fra = modf(minutes, &amp;minutes_int); // split integer and decimal part of minutes
      double seconds = minutes_fra*60; // decimal minutes in seconds
      stringstream ss;
      ss &lt;&lt; ("%02lf", hour_int) &lt;&lt; ":" &lt;&lt; ("%02lf", minutes_int) &lt;&lt; ":" &lt;&lt; ("%02lf", seconds);
      string time_obs_def = ss.str();
      cout &lt;&lt; time_obs_def &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>but the output is  1:5:7.1
  Thank you.</p>