title: Get current timestamp in microseconds since epoch?
body: <p>I have a below code from which we are trying to get current timestamp in microseconds since epoch time but we are using <code>steady_clock</code>.</p>
  
  <pre><code>inline uint64_t get_timestamp()
  {
      std::chrono::time_point&lt;std::chrono::steady_clock&gt; ts = std::chrono::steady_clock::now();
      return std::chrono::duration_cast&lt;std::chrono::microseconds&gt;(ts.time_since_epoch()).count();
  }
  </code></pre>
  
  <p>Is this the right way to do that since as per my understanding <code>steady_clock</code> is used to measure the passage of time not to get the current time of day? Or should I use <code>system_clock</code> for this like as shown below:</p>
  
  <pre><code>inline uint64_t get_timestamp()
  {
      std::chrono::time_point&lt;std::chrono::system_clock&gt; ts = std::chrono::system_clock::now();
      return std::chrono::duration_cast&lt;std::chrono::microseconds&gt;(ts.time_since_epoch()).count();
  }
  </code></pre>
  
  <p>I need to use <a href="http://en.cppreference.com/w/cpp/header/chrono" rel="noreferrer"><code>std::chrono</code></a> package only since that's what all our code is using.</p>