本文整理自网络,侵删。
function MyStrToDateTime(vStr: string): TDateTime; var S: string; v: Variant; begin Result := now; S := S := StringReplace(vStr, '.', '-', [rfReplaceAll]); S := StringReplace(S, '/', '-', [rfReplaceAll]); S := StringReplace(S, '\', '-', [rfReplaceAll]); S := StringReplace(S, ' ', '-', [rfReplaceAll]); S := StringReplace(S, '.', '-', [rfReplaceAll]); S := StringReplace(S, '/', '-', [rfReplaceAll]); S := StringReplace(S, '\', '-', [rfReplaceAll]); v := S; try Result := VarToDateTime(v); except end; end;
相关阅读 >>
Delphi 直接将html字符串读入webbrowser中
Delphi2010中使用pchar时e2010 incompatible types: 'char' and 'ansichar' 错误的处理
Delphi fdconnection查看所有表包含用户表和系统表
更多相关阅读请进入《Delphi》频道 >>