我从时间控件中读出的时间,怎么样才能转换成数值。。

解决方案 »

  1.   

    什么数据?说清楚啊。
    比如2003年4月13日,你想变成什么样子的啊? 20030413这样的吗?那不可以,int没有这么大。
      

  2.   

    CTime::GetTime()返回time_t类型,time_t其实就是long 型
      

  3.   

    MFC Library Reference   SYSTEMTIME Structure See Also
    Structures, Styles, Callbacks, and Message Maps | CTime::CTime
    The SYSTEMTIME structure represents a date and time using individual members for the month, day, year, weekday, hour, minute, second, and millisecond.typedef struct _SYSTEMTIME {
       WORD wYear;
       WORD wMonth;
       WORD wDayOfWeek;
       WORD wDay;
       WORD wHour;
       WORD wMinute;
       WORD wSecond;
       WORD wMilliseconds;
    } SYSTEMTIME;
    Parameters
    wYear 
    The current year. 
    wMonth 
    The current month; January is 1. 
    wDayOfWeek 
    The current day of the week; Sunday is 0, Monday is 1, and so on. 
    wDay 
    The current day of the month. 
    wHour 
    The current hour. 
    wMinute 
    The current minute. 
    wSecond 
    The current second. 
    wMilliseconds 
    The current millisecond. 
    Example
    // Retrieves the current system date and time.  The system 
    // time is expressed in Coordinated Universal Time (UTC). 
    SYSTEMTIME systime;
    GetSystemTime(&systime);// Determine day of the week.
    CString day;
    switch (systime.wDayOfWeek)
    {
    case 0:
       day = "Sunday";
       break;case 1:
       day = "Monday";
       break;case 2:
       day = "Tuesday";
       break;case 3:
       day = "Wednesday";
       break;case 4:
       day = "Thursday";
       break;case 5:
       day = "Friday";
       break;case 6:
       day = "Saturday";
       break;
    }// Show the time in a message box.
    char str[50];
    wsprintf(str, "%s %u/%u/%u  %u:%u:%u:%u", 
       day,
       systime.wYear, systime.wMonth, systime.wDay,
       systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);
    AfxMessageBox(str);
    See Also
    Structures, Styles, Callbacks, and Message Maps | CTime::CTime--------------------------------------------------------------------------------Send feedback to Microsoft© 2001 Microsoft Corporation. All rights reserved.
      

  4.   

    但是,我用GetTime得到的怎么是 0 ???
      

  5.   

    CTime tt(year,month,....);//用时间控件中获取的值构造
    time_t t1 = tt.GetTime();
      

  6.   

    CTime::GetTime()得到的是自1970年1月1日0点到CTime记录的时间所经历的秒数。
      

  7.   

    什么时间类型CTime还是COledateTime
    先声明6个int类型变量day,month,year,hour,minute,second,逐个复值
    格式:COledateTime(d,m,y,h,m,s);
      

  8.   

    COleDataTime好用。CTime不能小于1970年。
    COleDateTime可以大于0099年