I have a function that uses the Boost.DateTime library for generating the current GMT/UTC date and time string (live example).
std::string get_curr_date() {
Not answering your question as others have already done it. But, it's really not required to construct the locale everytime.
std::string get_curr_date_time() {
namespace bpt = boost::posix_time;
namespace bdt = boost::date_time;
std::ostringstream os;
auto date = bdt::second_clock::universal_time();
const static std::locale currlocale (os.getloc(), new bpt::time_facet("%Y%m%d%H%M%S"));
boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%a, %d %b %Y %H:%M:%S GMT");
os.imbue(currlocale);
os << date;
return os.str();
}