1、使用COleDateTime和COleDateTimeSpan类获取当月天数

```c ++ int GetThisMonthDays() { COleDateTime time, nextMonth; SYSTEMTIME stLocal; GetLocalTime(&stLocal); time.GetAsSystemTime(stLocal); time.SetDateTime(time.GetYear(), time.GetMonth(), 1, 0, 0, 0); if (time.GetMonth() >= 12) { nextMonth.SetDateTime(time.GetYear() + 1, 1, 1, 0, 0, 0); } else { nextMonth.SetDateTime(time.GetYear(), time.GetMonth() + 1, 1, 0, 0, 0); } COleDateTimeSpan ts = nextMonth - time; return ts.GetDays(); }

```c ++
// 取某年某月的天数
int GetMonthDays(int year, int month)
{
    if (month > 12 || month < 1)
    {
        return -1;
    }
    COleDateTime time, nextMonth;
    time.SetDateTime(year, month, 1, 0, 0, 0);

    if (time.GetMonth() >= 12)
    {
        nextMonth.SetDateTime(time.GetYear() + 1, 1, 1, 0, 0, 0);
    }
    else
    {
        nextMonth.SetDateTime(time.GetYear(), time.GetMonth() + 1, 1, 0, 0, 0);
    }
    COleDateTimeSpan ts = nextMonth - time;
    return ts.GetDays();
}

2、获取时区

```c ++ int GetTimeZone() { SYSTEMTIME t1, t2; GetLocalTime(&t1); GetSystemTime(&t2); int n = t1.wHour - t2.wHour; return n; }


### 3、当时时间
```c ++
    SYSTEMTIME stLocal;
    GetLocalTime(&stLocal);

4、系统时间

c ++ SYSTEMTIME stSys; GetSystemTime(&stSys);