I\'m working with the Azure REST API and they are using this to create the request body for table storage:
DateTime.UtcNow.ToString(\"o\")
I should point out I am a C++ newb.
I needed string with a UTC ISO 8601 formatted date and time that included milliseconds. I did not have access to boost.
This is more of a hack than a solution, but it worked well enough for me.
std::string getTime()
{
timeval curTime;
gettimeofday(&curTime, NULL);
int milli = curTime.tv_usec / 1000;
char buf[sizeof "2011-10-08T07:07:09.000Z"];
strftime(buf, sizeof buf, "%FT%T", gmtime(&curTime.tv_sec));
sprintf(buf, "%s.%dZ", buf, milli);
return buf;
}
The output looks like: 2016-04-13T06:53:15.485Z