Help to get in the variable day of the month. In general, I can not imagine how to do it. Or maybe someone has information on this topic ... Thanks in advance.

  • What platform and compiler? - KoVadim
  • windows xp in visual studio 2008 - FFF

4 answers 4

If on pure C ++ and on Windows, this is done through the time function with the subsequent conversion of the result into the tm structure by the localtime function. The tm structure contains the required field:

struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; ///< то что требуется int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; }; 

    Use the SYSTEMTIME structure paired with the GetSystemTime() function:

     #include <windows.h> #include <iostream> void main() { SYSTEMTIME st; GetSystemTime(&st); std::cout << st.wDay; // Вывод дня месяца } 
        #include <atltime.h> 

      ///////// Some code

        int Month=CTime::GetMonth(); 

      Like that...

         SYSTEMTIME st; GetSystemTime(&st); cout << to_string(st.wMinute) + "-" + to_string(st.wHour) + "." + to_string(st.wDay) + "." + to_string(st.wMonth) + "." + to_string(st.wYear) << endl;