我用的是DATA Time
但是我只能设置为1970年1月1日——2039年12月31日这个范围之内
其他时间就不能设置了。。
我从DATA Time控件上得到的值通过Format(%Y,%m,%d)转换以后就为空了。。不知道为什么请教高手
我需要将它转换为CString

解决方案 »

  1.   

    COleDateTime now;
    now=now.GetCurrentTime();
    //GetCurrentTime()取得时间与time(time_t*timer);和structtm*localtime(consttime_t*timer);所得时间相同只能到2037年
    //而GetLocalTime(&sysTime);可到9999年
    m_year=now.GetYear();//年
    m_month=now.GetMonth();//月
    m_day=now.GetDay();//日CStringcs;
    cs.Format("%d年%d月%d日",m_year,m_month,m_day);
      

  2.   

    // TODO: Add your control notification handler code here
    CTime time;
    time = CTime::GetCurrentTime();
    CString str1 = time.Format("%A, %B %d, %Y" ); //星期?,?月?日,?年
    CString str2 = time.Format("%D, %H, %M, %S %%"); 
    /*%D   Total days in this CTime
              %H   Hours in the current day
              %M   Minutes in the current hour
              %S   Seconds in the current minute
              %%   Percent sign*/
        int day = time.GetDay();
    int month = time.GetMonth();
    int year = time.GetYear();
    CString str3;
    str3.Format("Day=>%d Month=>%d year=>%d",day,month,year);
    CString msg;
    msg = str1 + "\n" + str2+"\n"+str3;
    AfxMessageBox(msg);
      

  3.   

    我所需要的不是系统时间。而是我用DATATime控件得到的时间它的类型为CTime格式
    不知道怎么样将其Format才能没有限制
      

  4.   

    假如我从控件选择的时间为1900-01-01
    怎么样将CTime格式的1900-01-01转换成为CString格式呢。。CTime格式好象不能存储1900-01-01这个时间,好象超出了存储范围.
      

  5.   

    6.0是不支持的,都是以GMT时间为标准,从January 1, 1970, 到 January 18, 19:14:07, 2038.
      

  6.   

    给你一个经典的API函数GetLocalTime,很精确而且不受限制:         CString sTime,sYear,sMonth,sDay;
             SYSTEMTIME CurTime;
             GetLocalTime(&CurTime);
    sYear.Format("%d年",CurTime.wYear);
    sMonth.Format("%d月",CurTime.wMonth);
    sDay.Format("%d日",CurTime.wDay);
    sTime =  sYear+ sMonth + sDay;