I have this C++ function:
string date()
{
time_t seconds = time (NULL);
struct tm * timeinfo = localtime (&seconds);
ostringstream oss;
oss << (timeinfo->tm_year + 1900) << "-" << (timeinfo->tm_mon + 1) << "-" << timeinfo->tm_mday;
string data = oss.str();
return data;
}
The problem is I wanted the month and day with 0's. It's returning '2013-6-1' instead of '2013-06-01'
I'm trying to get this right with some if's and else's but I'm not getting anywhere..
Could you please help me?