delphi中的strTodate,

delphi中StrToDate和当前操作系统设定的日期格式有关,格式不一致时,会抛出错误。

最好在调用时,强制转换,如下

var


t:TDateTime;


fs:TFormatSettings;


begin


fs.ShortDateFormat:='yyyy-mm-dd';


fs.DateSeparator:='-';


t := StrToDate('2010-01-01',fs);