title: How to convert std::chrono::high_resolution_clock::now() to milliseconds, microseconds, ...?
body: <p>I got this code from <a href="https://stackoverflow.com/questions/14391327/how-to-get-duration-as-int-millis-and-float-seconds-from-chrono">How to get duration, as int milli&#39;s and float seconds from &lt;chrono&gt;?</a></p>
  
  <pre><code>#include &lt;chrono&gt;
  #include &lt;iostream&gt;
  
  int main (int argc, char *argv[])
  {
    auto t0 = std::chrono::high_resolution_clock::now();
    auto t1 = std::chrono::high_resolution_clock::now();
  
    std::chrono::duration&lt; double &gt; fs = t1 - t0;
    std::chrono::milliseconds d = std::chrono::duration_cast&lt; std::chrono::milliseconds &gt;( fs );
  
    std::cout &lt;&lt; fs.count() &lt;&lt; "s\n";
    std::cout &lt;&lt; d.count() &lt;&lt; "ms\n";
  }
  </code></pre>
  
  <p>Which works perfectly, but how I can create a time stamp with:</p>
  
  <pre><code>hour:minute:second:millisecond:microsecond:nanosecond
  </code></pre>
  
  <p>Using the <code>auto t0 = std::chrono::high_resolution_clock::now()</code> value?</p>
  
  <p>I tried to print the <code>auto t0 = std::chrono::high_resolution_clock::now();</code> value, to see what it had inside, however it only gave me a big error stack:</p>
  
  <pre><code>#include &lt;chrono&gt;
  #include &lt;iostream&gt;
  
  int main (int argc, char *argv[])
  {
    auto t0 = std::chrono::high_resolution_clock::now();
    std::cout &lt;&lt; t0 &lt;&lt; "\n";
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>main2.cpp: In function 'int main(int, char**)':
  main2.cpp:10:13: error: no match for 'operator&lt;&lt;' (operand types are 'std::ostream {aka std::basic_ostream&lt;char&gt;}' and 'std::chrono::time_point&lt;std::chrono::_V2::system_clock, std::chrono::duration&lt;long long int, std::ratio&lt;1, 1000000000&gt; &gt; &gt;')
     std::cout &lt;&lt; t0 &lt;&lt; "\n";
     ~~~~~~~~~~^~~~~
  </code></pre>