为什么这不能尝试更改DateSeparator

时间:2018-02-15 23:30:14

标签: delphi-10.2-tokyo

<form method="POST" action="">

val Before =&#39; 10-23-2008 11:43:54&#39;

结果= 10/23/2008 11:43:54 AM

显然System.SysUtils.FormatSettings.DateSeparator := '-'; result := StrToDateTime(Trim(val)); System.SysUtils.FormatSettings.DateSeparator := '/'; 未设置。为什么呢?

1 个答案:

答案 0 :(得分:0)

您在调用DateSeparator之前设置了StrToDateTime()(仅供参考,您应该使用TFormatSettings的{​​{1}}重载版本,而不是使用全局StrToDateTime()变量在所有)。很明显,System.SysUtils.FormatSettings确实生效了您展示的DateSeparator

您的ResultResult,而不是TDateTime。如果您正在评估调试器中的String,那么在运行时设置RTL的格式化变量对调试器没有影响。如果您正在以其他方式评估Result,则不会显示/解释如何。

相关问题