title: How to get current timestamp in milliseconds since 1970 just the way Java gets
body: <p>In Java, we can use <code>System.currentTimeMillis()</code> to get the current timestamp in Milliseconds since epoch time which is -</p>
  
  <blockquote>
    <p>the difference, measured in milliseconds, between the current time and
    midnight, January 1, 1970 UTC.</p>
  </blockquote>
  
  <p>In C++ how to get the same thing?</p>
  
  <p>Currently I am using this to get the current timestamp - </p>
  
  <pre><code>struct timeval tp;
  gettimeofday(&amp;tp, NULL);
  long int ms = tp.tv_sec * 1000 + tp.tv_usec / 1000; //get current timestamp in milliseconds
  
  cout &lt;&lt; ms &lt;&lt; endl;
  </code></pre>
  
  <p>This looks right or not?</p>