首页 > 代码库 > 时间格式

时间格式

1、

var  fmtSettings: TFormatSettings;  dt: TDateTime;begin  Memo1.Lines.Add(DateTimeToStr(Now));  Memo1.Lines.Add(‘‘);  GetLocaleFormatSettings(GetUserDefaultLCID, fmtSettings);  Memo1.Lines.Add(fmtSettings.ShortDateFormat);  Memo1.Lines.Add(fmtSettings.ShortTimeFormat);  Memo1.Lines.Add(fmtSettings.LongDateFormat);  Memo1.Lines.Add(fmtSettings.LongTimeFormat);  Memo1.Lines.Add(fmtSettings.ThousandSeparator);  Memo1.Lines.Add(‘‘);    fmtSettings.DateSeparator := /;  fmtSettings.TimeSeparator := :;  fmtSettings.ShortDateFormat := yyyy/mm/dd;  fmtSettings.ShortTimeFormat := hh:nn:ss;  dt:= StrToDateTime(2010/3/19 08:09:10, fmtSettings);  Memo1.Lines.Add(DateTimeToStr(dt));  Memo1.Lines.Add(‘‘);  fmtSettings.DateSeparator := /;  fmtSettings.ShortDateFormat := yyyy/mm/dd;  fmtSettings.TimeSeparator := :;  //fmtSettings.ShortTimeFormat := ‘hh:nn:ss‘;  Memo1.Lines.Add(DateTimeToStr(dt, fmtSettings));  Memo1.Lines.Add(DateTimeToStr(now, fmtSettings));end;

 

2、输出:

Memo12016-10-08 22:42:20yyyy-MM-ddh:mmyyyy‘年‘M‘月‘d‘日‘h:mm:ss,2010-03-19 8:09:102010/03/19 8:09:102016/10/08 22:42:20

 

3、

4、

5、

 

时间格式