“xx-xx-xx不是有效的日期和时间值”错误 [英] "xx-xx-xx is not a valid date and time value" Error
问题描述
从我的最后一次问题,每当我在具有不同日期/时间格式的系统上运行时,我仍然会收到错误。我使用日期编辑和时间编辑框来选择我的日期和时间值。日期编辑格式为 dd-mm-yy
,而我的时间编辑形成为 hh:mm
。当我将其保存到TDateTime变量 dtLastOnline
时,我得到'xx-xx-xx不是有效的日期和时间值'错误。
Following up from my last question, I still get the error whenever I run it on a system with a different date/time format. I am using a Date Edit, and a Time Edit-box to select my date and time value. The Date Edit is formatted as dd-mm-yy
, and my Time Edit is formated as hh:mm
. When I save them to the TDateTime variable dtLastOnline
I get the 'xx-xx-xx is not a valid date and time value' error.
我设置我的dtLastOnline像 dtLastOnline:= dedtLastOnline.Date + tpLastOnline.Time;
I set my dtLastOnline like dtLastOnline := dedtLastOnline.Date + tpLastOnline.Time;
如何确保我的应用程序具有相同的日期/时间格式,无论从哪里运行?
How to I make sure my app has the same Date/Time format wherever it is being run from?
我尝试设置ShortDateFormat,LongDateFormat等,但是赢了
I tried setting the ShortDateFormat, LongDateFormat, etc, but that won't work.
谢谢!
推荐答案
TDateTimePickers,一组保存数据,一个持有时间。这是你在做什么?
I tried with two TDateTimePickers, one set to hold a data, and one to hold a time. Is that what you are doing?
我发现以下内容对我来说没有错误:
I find that the following works for me with no errors:
var
dt: TDateTime;
...
dt := DateOf(DatePicker.Date) + TimeOf(TimePicker.Time);
ShowMessage(FormatDateTime('c', dt));
输出是:
这篇关于“xx-xx-xx不是有效的日期和时间值”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!