The easiest way (boost allowed) to get a "yyyymmdd" date string in C++
<p>Can you name me some dead-easy way of getting the current "yyyymmdd" (e.g. "20121219") string from C++? Boost is allowed, so that should make it easier. I could use <code>ctime</code> but it's a bit of a pain to set up that structure.</p>

<p>I already did this</p>

<pre><code>boost::gregorian::date current_date(boost::gregorian::day_clock::local_day());
int year_int = current_date.year();
int month_int = current_date.month();
int day_int = current_date.day();
</code></pre>

<p>and then converting the <code>int</code>s to <code>string</code>s using</p>

<pre><code>std::string year = boost::lexical_cast&lt;std::string&gt;(year_int);
std::string month = boost::lexical_cast&lt;std::string&gt;(month_int);
std::string day = boost::lexical_cast&lt;std::string&gt;(day_int);
</code></pre>

<p>But the problem with this is that day 1 will be "1" instead of "01" as it should be.</p>
