C++ :: Boost :: posix_time (elapsed seconds. elapsed fractional seconds)
<p>I'm trying to come up with an answer to two questions that didn't seem hard at first.
Q1 : How do I obtain the number of elapsed seconds between UTC.Now() and a given date?
A1 : Just like in the code below!
Q2 : How do I determine how many fractional seconds have elapsed since the last "full" second ? I'd like to print the "total_elapsed_seconds.fractional_seconds" -> "1234124.45". How do I do that?
A2 : ???</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;boost/date_time/gregorian/gregorian.hpp&gt;
#include &lt;boost/date_time/posix_time/posix_time.hpp&gt;

using namespace std;
using namespace boost::gregorian;
using namespace boost::posix_time; 

void main()
{
    ptime Jan1st1970(date(1970, 1, 1));
    for(int i = 0; i &lt; 10; i++)
    {
     ptime Now = second_clock::universal_time();
     time_duration diff = Now - Jan1st1970;
     cout &lt;&lt; Now &lt;&lt; " : " &lt;&lt; diff.total_seconds() &lt;&lt; "." &lt;&lt; diff.fractional_seconds() &lt;&lt; endl;
    }
}
</code></pre>
