title: Convert boost::posix_time::ptime to NTP Timestamp
body: <p>I have a device which gives me boost::posix_time::ptime thorugh its API. To sychronize with other Data I need the time as NTP timestamp, differentiated in NTP seconds and NTP fract_seconds.</p>
  
  <p>I tried something like:</p>
  
  <pre><code>#include "boost/date_time/posix_time/posix_time.hpp"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  using boost::posix_time::ptime;
  using boost::posix_time::time_duration;
  using boost::gregorian::date;
  
  int main() 
    {
      ptime t = boost::posix_time::microsec_clock::local_time();
  
      ptime myEpoch(date(1900,boost::gregorian::Jan,1));
  
      time_duration myTimeFromEpoch = t - myEpoch;
  
      boost::uint64_t myTimeAsInt = myTimeFromEpoch.ticks();
  
      cout &lt;&lt; myTimeAsInt &lt;&lt; endl;
  
      boost::uint32_t seconds = (boost::uint32_t)((myTimeAsInt &gt;&gt; 32) &amp; 0xFFFFFFFF);
  
      boost::uint32_t fraction = (boost::uint32_t)(myTimeAsInt &amp; 0xFFFFFFFF);
  
      cout &lt;&lt; seconds &lt;&lt; endl;
      cout &lt;&lt; fraction &lt;&lt; endl;
  
      return 0;
    }
  </code></pre>
  
  <p>But it does not give me the correct results? Any help appreciated.</p>