Skip to content

Instantly share code, notes, and snippets.

@Answeror
Created May 13, 2013 06:09
Show Gist options
  • Save Answeror/5566446 to your computer and use it in GitHub Desktop.
Save Answeror/5566446 to your computer and use it in GitHub Desktop.
Get total seconds since 1970-01-01, millisecond precision.
#include <boost/date_time/posix_time/posix_time.hpp>
double current_time()
{
using namespace boost::gregorian;
using namespace boost::posix_time;
const boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
ptime time_t_epoch(date(1970,1,1));
time_duration diff = now - time_t_epoch;
return diff.total_milliseconds() / 1000.0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment