有一个Combo Box组合框里面有不同国家的地区如:北京,上海,悉尼,伦敦,华盛顿....等等(有很多城市),有一个编辑框Edit用来显示在选择组合框里的地区的当前时间:年,月,日,时,分,秒。
我知道获取系统的当前时间:CTime time = CTime::GetCurrentTime();但是不知道要如何转换成不同地区的时间。

解决方案 »

  1.   

    好像没有专门的API函数,必须自己转换这有一个时区时间转换的例子
    格林威治时间转换为北京时间
    http://blog.vckbase.com/teacheryang/archive/2008/04/27/33438.html
      

  2.   

    获得系统时区,之后用转换下你要的时区就行了TIME_ZONE_INFORMATION   tzi;   
    GetSystemTime(&tzi.StandardDate);   
    GetTimeZoneInformation(&tzi);   
        
    CString   strStandName   =   tzi.StandardName;   
    CString   strDaylightName   =   tzi.DaylightName;   
    CString   strInfo;   
    strInfo.Format(_T("%s:时区%d,%s:时差%d小时"),strStandName,tzi.Bias   /   -60,strDaylightName,tzi.DaylightBias   /   -60);   
    AfxMessageBox(strInfo);
      

  3.   

    用COleDateTime和COleDateTimeSpan加减小时很方便的。