我要临时更改为英语,取得英语格式化的日期。
在控制面板中可以设置为其它区域,但不知道用delphi怎么做,好像是用SetLocalInfo,但不知道怎么用。

解决方案 »

  1.   

    需要格式化为 23 may 2004这样的格式。
      

  2.   

    //好象没有现成的函数, 自己写吧procedure TForm1.Button1Click(Sender: TObject);
      function FormatDateEx(ds: TDate): String;
      var
        day, month, year: Word;
        sMonth: String;
      begin
        sMonth := '';
        DecodeDate(ds, year, month, day);
        case month of
          1: sMonth := 'Jan';
          2: sMonth := 'Feb';
          3: sMonth := 'Mar';
          4: sMonth := 'Apr';
          5: sMonth := 'May';
          6: sMonth := 'Jun';
          7: sMonth := 'Jul';
          8: sMonth := 'Aug';
          9: sMonth := 'Sep';
          10: sMonth := 'Oct';
          11: sMonth := 'Nov';
          12: sMonth := 'Dec';
        end;
        Result := IntToStr(day) + ', ' + sMonth + ', ' + IntToStr(year);
      end;
    begin
      ShowMessage(FormatDateEx(Date));
    end;
      

  3.   

    http://big5.pconline.com.cn/b5/www.pconline.com.cn/pcedu/empolder/gj/delphi/0402/321690_1.htmlLOCALE_SPOSITIVESIGN
      LOCALE_ITIME LOCALE_SSHORTDATE
      LOCALE_S1159 LOCALE_STHOUSAND
      LOCALE_S2359 LOCALE_STIME
      LOCALE_SCURRENCY LOCALE_STIMEFORMAT
      lpLCData:需要設定的資訊的存放地址;  與起對應的函數為  int GetLocaleInfo(  LCID Locale, // locale identifier 
      LCTYPE LCType, // type of information 
      LPTSTR lpLCData, // address of buffer for information 
      int cchData // size of buffer 
      ); 
      主要用於取得目前系統的區域設定,各個參數和使用過程不再一一說明。  3 使用舉例  //取得目前系統的短日期格式;
      function Tfrmmain.GetsysDateFormat: string;
      var
      sgs:string;
      begin
      setlength(sgs,12);
      GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SSHORTDATE ,PChar(sgs),12);
      result:=string(pchar(sgs));
      end;  //設定系日期格式;
      procedure Tfrmmain.SetSysDateFormat(s: string);
      begin
      SetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SSHORTDATE,PChar(s));
      end;
    http://zealot.yculblog.com/post-48091.html