- SysUtils.StrToDate();
- SysUtils.StrToDateDef();
- SysUtils.TryStrToDate();
-
- SysUtils.StrToTime();
- SysUtils.StrToTimeDef();
- SysUtils.TryStrToTime();
-
- SysUtils.StrToDateTime();
- SysUtils.StrToDateTimeDef();
- SysUtils.TryStrToDateTime();
-
- SysUtils.DateToStr();
- SysUtils.TimeToStr();
- SysUtils.DateTimeToStr();
- SysUtils.DateTimeToString();
-
- SysUtils.FormatDateTime();
- SysUtils.FormatDateTime(); 函数参见:
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs;
-
- type
- TForm1 = class(TForm)
- procedure FormCreate(Sender: TObject);
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.dfm}
-
- uses DateUtils;
-
- procedure TForm1.FormCreate(Sender: TObject);
- var
- d: TDateTime;
- str: string;
- fmt: TFormatSettings;
- begin
- d := StrToDateTime('2009-5-21 11:22:33');
-
- str := DateTimeToStr(d);
- ShowMessage(str);
-
- GetLocaleFormatSettings(GetThreadLocale, fmt);
- fmt.DateSeparator := '/';
- fmt.TimeSeparator := '_';
- fmt.ShortDateFormat := 'dd/mm/yyyy';
- fmt.ShortTimeFormat := 'hh:mm:ss';
- str := DateTimeToStr(d, fmt);
- ShowMessage(str);
-
- DateTimeToString(str, 'yyyy 年 m 月 d 日 h 点 m 分 s 秒', d);
- ShowMessage(str);
- end;
-
- end.
|
请发表评论