SysUtils.StrToDate('20/11/2012 7:05:14 PM')抛出一个赘肉.如何TDateTime从该字符串中获取?
要避免此类问题,必须使用StrToDateTime传递TFormatSettings值的方法,并使用要转换的字符串格式的设置.
var
AFormatSettings: TFormatSettings;
LDateTime : TDateTime;
begin
AFormatSettings:=TFormatSettings.Create;
AFormatSettings.ShortDateFormat:='dd/mm/yyyy';
AFormatSettings.DateSeparator:='/';
LDateTime:= StrToDateTime('20/11/2012 7:05:14 PM', AFormatSettings);
Run Code Online (Sandbox Code Playgroud)