I want to format a date/time to a string using boost.
Starting with the current date/time:
ptime now = second_clock::universal_time();
// create your date
boost::gregorian::date d(2009, 1, 7);
// create your formatting
boost::gregorian::date_facet *df = new boost::gregorian::date_facet("%Y%m%d_%H%M%S");
// set your formatting
ostringstream is;
is.imbue(std::locale(is.getloc(), df));
is << d << endl;
// get string
cout << "output :" << is.str() << endl;