现成的方法没用过,不过可以自己写一个呗,掐头去尾后再用format即可。
Function GetTimes(ByVal GmtTime As String) As String
    If Len(Trim(GmtTime)) = 0 Then Exit Function
    If InStr(1, GmtTime, " gmt", vbTextCompare) = 0 Then Exit Function
    Dim t1 As String
    t1 = Replace(GmtTime, "gmt", "", 1, , vbTextCompare)
    t1 = Right$(t1, Len(t1) - InStr(1, t1, ",", vbTextCompare))
    GetTimes = Format$(t1, "yyyy-mm-dd hh:nn:ss")
End Function
Sub tes()
    Debug.Print GetTimes("Tue, 23 Sep 2014 17:16:52 GMT")
End Sub

解决方案 »

  1.   

    好像CDATE不行, 这个字符串中包含了不能解析的字符. 
    你可以把前面的星期和后面的时区去掉之后再转换.前面是逗号隔开的, 后面是空格隔开的
    先用split函数分隔再转换吧.
      

  2.   

    仅供参考#include <stdio.h>
    #include <string.h>
    #include <time.h>
    struct tm st;
    time_t tt;
    char timstr[40];
    char tmpbuf[128];
    char c;
    int t;
    int AP() {
        if ('P'==c || 'p'==c) {st.tm_hour+=12;return 1;}
        if ('A'==c || 'a'==c)                 return 1;
                                              return 0;
    }
    int dtparse() {
        if (7==sscanf(timstr,"%d/%d/%4d %d:%d:%d %c",&st.tm_mday,&st.tm_mon ,&st.tm_year,&st.tm_hour,&st.tm_min,&st.tm_sec,&c)) if (AP()) goto STEP2;
        if (6==sscanf(timstr,"%d/%d/%4d %d:%d%c"    ,&st.tm_mday,&st.tm_mon ,&st.tm_year,&st.tm_hour,&st.tm_min           ,&c)) if (AP()) goto STEP1;
        if (6==sscanf(timstr,"%4d/%d/%d %d:%d %c"   ,&st.tm_year,&st.tm_mon ,&st.tm_mday,&st.tm_hour,&st.tm_min           ,&c)) if (AP()) goto STEP1;
        if (5==sscanf(timstr,"%d.%d.%4d %d:%d"      ,&st.tm_mon ,&st.tm_mday,&st.tm_year,&st.tm_hour,&st.tm_min              ))           goto STEP1;
        if (6==sscanf(timstr,"%4d-%d-%d %d:%d:%d"   ,&st.tm_year,&st.tm_mon ,&st.tm_mday,&st.tm_hour,&st.tm_min,&st.tm_sec   ))           goto STEP2;
    STEP1:
        st.tm_sec=0;
    STEP2:
        st.tm_year-=1900;
        if (st.tm_mon>12) {t=st.tm_mon;st.tm_mon=st.tm_mday;st.tm_mday=t;}
        st.tm_mon-=1;
        tt=mktime(&st);
        if (-1!=tt) {
            strftime(tmpbuf,128,"%Y-%m-%d %H:%M:%S",localtime(&tt));
            return 1;
        } else {
            printf("[%s] is Invalid time string!\n",timstr);
            return 0;
        }
    }
    int main() {
        strcpy(timstr,"10.01.2012 15:43"        );if (dtparse()) printf("[%s] is [%s]\n",timstr,tmpbuf);
        strcpy(timstr,"8/11/2006 11:10AM"       );if (dtparse()) printf("[%s] is [%s]\n",timstr,tmpbuf);
        strcpy(timstr,"2006/10/31 04:50 PM"     );if (dtparse()) printf("[%s] is [%s]\n",timstr,tmpbuf);
        strcpy(timstr,"1/6/2010 5:20:12 PM"     );if (dtparse()) printf("[%s] is [%s]\n",timstr,tmpbuf);
        strcpy(timstr,"13/12/2012 11:16:17 a.m.");if (dtparse()) printf("[%s] is [%s]\n",timstr,tmpbuf);
        strcpy(timstr,"2013-06-08 09:56:59"     );if (dtparse()) printf("[%s] is [%s]\n",timstr,tmpbuf);
        return 0;
    }
    //[10.01.2012 15:43] is [2012-10-01 15:43:00]
    //[8/11/2006 11:10AM] is [2006-11-08 11:10:00]
    //[2006/10/31 04:50 PM] is [2006-10-31 16:50:00]
    //[1/6/2010 5:20:12 PM] is [2010-06-01 17:20:12]
    //[13/12/2012 11:16:17 a.m.] is [2012-12-13 11:16:17]
    //[2013-06-08 09:56:59] is [2013-06-08 09:56:59]
    //
      

  3.   

    再供参考:#include <stdio.h>
    #include <string.h>
    #include <time.h>
    #include <sys/timeb.h>struct tm st;
    time_t tt;
    char mon[4];
    char mn[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
    int i;
    char timstr[27];
    char tmpbuf[128];
    struct _timeb tb;
    int tz;
    char c;void main() {
        strcpy(timstr,"08/Dec/2011:15:25:03 +0800");
        sscanf(timstr,"%2d/%3s/%4d:%2d:%2d:%2d",&st.tm_mday,mon,&st.tm_year,&st.tm_hour,&st.tm_min,&st.tm_sec);
        for (i=0;i<12;i++) if (0==stricmp(mn[i],mon)) {st.tm_mon=i; break;}
        st.tm_year-=1900;
        tt=mktime(&st);
        if (-1!=tt) {
            strftime(tmpbuf,128,"%Y-%m-%d %H:%M:%S\n",localtime(&tt));
            printf(tmpbuf);//2011-12-08 15:25:03
        } else {
            printf("[%s] is Invalid time string!\n",timstr);
        }    _ftime(&tb);
        strftime(tmpbuf,128,"%m/%b/%Y:%H:%M:%S",localtime(&tb.time));
        tz=-tb.timezone;
        c=(tz>0)?'+':'-';
        tz=(tz>0)?tz:-tz;
        sprintf(tmpbuf,"%s %c%02d%02d\n",tmpbuf,c,tz/60,tz%60);
        printf(tmpbuf);//12/Dec/2011:17:36:41 +0800
    }