问题描述
我的表单上有一个DateTimePicker控件,显示英国格式的日期
格式(年/月/日)。
但是,在我的代码中,dtpStartDate.Value以美国格式提供日期,但
dtpStartDate.Value.ToString()以所需的英国格式提供日期!
有任何想法吗?所有系统区域设置都设置为英国/英国设置。
I have a DateTimePicker control on my form that is displaying the date
format in UK format (dd/mm/yy).
However, in my code dtpStartDate.Value gives a date in US format, but
dtpStartDate.Value.ToString() gives the date in the required UK format!
Any ideas? All system locale settings are set to British/UK settings.
推荐答案
DateTimePicker.Value不是*任何*特定格式 - 它只是一个
DateTime。你是什么意思给出一个美国格式的日期?
-
Jon Skeet - < sk *** @ pobox.com> ;
如果回复小组,请不要给我发邮件
DateTimePicker.Value isn''t in *any* particular format - it''s just a
DateTime. What do you mean by "gives a date in US format"?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
DateTimePicker.Value不是*任何*特定格式 - 它只是一个
DateTime。你是什么意思以美国格式提供日期?
DateTimePicker.Value isn''t in *any* particular format - it''s just a
DateTime. What do you mean by "gives a date in US format"?
当我将DateTimePicker的值赋给DateTime变量时,它是
当我单步执行代码时,以美国格式(dd / mm / yy)
。然后,当我尝试将
作为参数传递给SQL Server存储过程时,由于日期无效(例如今天是11/25 / 2003年这不是有效的
英国约会,但是11/11/2003工作正常。
When I assign the value of the DateTimePicker to a DateTime variable, it is
in US format (dd/mm/yy) when I step through the code. When I then try and
pass this date as a parameter to a SQL Server stored procedure it falls over
as the date is invalid (for example today is 11/25/2003 which isn''t a valid
UK date, but 11/11/2003 works fine).
这篇关于DateTimePicker日期格式怪异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!