string currentDateToString()
{
time_t now = time(0);
tm *ltm = localtime(&now);
string dateString = "", tmp = "";
tmp = numToString(ltm->tm_mday);
if (tmp.length() == 1)
tmp.insert(0, "0");
dateString += tmp;
dateString += "-";
tmp = numToString(1 + ltm->tm_mon);
if (tmp.length() == 1)
tmp.insert(0, "0");
dateString += tmp;
dateString += "-";
tmp = numToString(1900 + ltm->tm_year);
dateString += tmp;
dateString += " ";
tmp = numToString(ltm->tm_hour);
if (tmp.length() == 1)
tmp.insert(0, "0");
dateString += tmp;
dateString += ":";
tmp = numToString(1 + ltm->tm_min);
if (tmp.length() == 1)
tmp.insert(0, "0");
dateString += tmp;
dateString += ":";
tmp = numToString(1 + ltm->tm_sec);
if (tmp.length() == 1)
tmp.insert(0, "0");
dateString += tmp;
return dateString;
}
Code Example |
---|
:: c++ get line |
:: |
:: |
:: |
:: |
Cpp :: |
Cpp :: Sort html elements in Jquery on condition |
:: |
:: |
:: |
Cpp :: |
Cpp :: how to get hcf of two number in c++ |
:: |
Cpp :: c++ thread |
:: |
:: |
:: |
:: c++ class template |
:: |
:: |
Cpp :: |
:: |
:: convert wchar_t to to multibyte |
Cpp :: |
Cpp :: |
Cpp :: |
:: arduino falling edge |
:: |
:: |
Cpp :: Temparory Email Id |