请问这个该如何实现呢?感谢大家需要用字符串的形式保存所有时间unsigned int m_iNedTi=m_iNeedMoney/m_iTotalMins;//  时间=所需金钱/每分钟得到的金钱 如50000分钟
//将分钟转化成为年月日时分秒的格式 如1年2月3天4小时5分。
//需要跟此刻的时间比较后,得到一个预期的时间。 如此刻2009年03月06日 14:32:23,加上1年2月3天4小时5分6秒,得到预期时间:2010年5月9日 16:37:29秒         

解决方案 »

  1.   

    COleDateTime 和 COleDateTimeSpan
    COleDateTime tm1, tm2;
    COleDateTimeSpan tmsp = tm2 - tm1;
    tm2 = tm1 + tmsp;
    CString str = tm1.Format("YYYY-mm-dd HH:MM:SS");
      

  2.   

    unsigned int m_iNedTi=m_iNeedMoney/m_iTotalMins;//  时间=所需金钱/每分钟得到的金钱 如50000分钟
    //那请问如何将50000分钟转化成为年月日时分秒的格式 如1年2月3天4小时5分呢?
      

  3.   

    //COleDateTime 和 COleDateTimeSpan的用法最好查一下msdn
    COleDateTime tm1;
    tm = COleDateTime::GetCurrentTime(); //tm1中保存当前时间。
    COleDateTime tmsp;
    tmsp.SetDateTimeSpan(0, 50000, 0, 0); //tmsp为50000小时
    COleDateTime tm2;
    tm2 = tm1 + tmsp; //tm2是tm1 加上50000小时的时间。
    CString str = tm2.Format("YYYY年mm月dd日 HH:MM:SS"); //格式化输出tm2
      

  4.   

    COleDateTime tm1;
    tm1 = COleDateTime::GetCurrentTime(); //tm1中保存当前时间。
    /*COleDateTime*/COleDateTimeSpan tmsp;
    tmsp.SetDateTimeSpan(0,0 , m_iNedTi, 0); //tmsp为50000小时
    COleDateTime tm2;
    tm2 = tm1 + tmsp; //tm2是tm1 加上50000小时的时间。
             str = tm2.Format("%Y-%m-%d %H:%M:%S"); //格式化输出tm2

    // str = tm2.Format("YYYY年mm月dd日 HH:MM:SS"); //格式化输出tm2
    AfxMessageBox(str);
    ok 了 感谢!!