English 中文(简体)
C#中与时俱进的文化转变
原标题:Culture-conversion in C# with DateTime

我会遇到麻烦,使我的ASPX-App在生产服务器上工作。 由于我的当地环境比较好,但服务器为 english,而我整个代码则提供文化支持,我目前正在在整个文字中执行。

各位可能认为,正如我在这里写这句话一样,它并没有很好地发挥作用。

管理局利用MSSQL-Data基收集基于日期安排的信息。 因此,我使用用户选择的计算日期(<代码>)。 日期: BETWEEN x and y 。

日期由用户确定,并按规定按现时价值处理:

_DateRangeStart = DateTime.Parse(DateStart + " 00:00:00", _Culture);
_DateRangeEnd = DateTime.Parse(DateEnd + " 23:59:59", _Culture);

<代码>_Culture的定义如下:

public CultureInfo _Culture = CultureInfo.GetCultureInfo("de-DE");

_DateRangeStart (and End) 是文本现场的用户输入。

因此,由于我看上了这块rip子,它向我表明,用户投入从1.11.2009转变。 (正确日期) to 11/1/2009 00:00:00 AM, which should be 1.11.2009 00:00:00<0 (for_DateRangeStart).

这一数值不能由Kall来读,它给我留下一个错误,即不可能将果园改成有效日期。

为什么不正确转换?

最佳回答

我猜想你在你的日期变数上叫ToString(),并以缺省格式计算产出。 然后,法国空研中心试图以违约的形式解释它,失败。 我认为,你需要做的是,以明确的格式安排这一日期,并将其送至服务器。

E.g.

  string myDate = _DateRangeStart.ToString("yyyy-MM-dd");
问题回答

您的ql服务器是否为另一种文化而不是脱-? 这也会造成这种行为。 如果你的服务器认为他是一个美国人,他就希望美国格式的日期。





相关问题
Weird Time Issue in Python

Problem with using times in Python. Terminal > Python >>> calendar.timegm(datetime.datetime.now().utctimetuple()) 1258449380 This time indicates GMT: Tue, 17 Nov 2009 09:16:20 GMT Eclipse ...

How does a .NET process get the culture information?

I have a Windows service running (C#, .NET 2.0) on Windows Server 2003 R2. In one server the System.Threading.Thread.CurrentThread.CurrentCulture is {en-AU} and in the other {en-US}. This has caused a ...

Best way to get maximum Date value in java?

I m writing a bit of logic that requires treating null dates as meaning forever in the future (the date in question is an expiration date, which may or may not exist). Instead of putting in special ...

Date format in SQL Server

Short Question: What s the best date format to use in SQL Server? Long Explanation: We re converting our database from mysql to SQL Server. In mysql we always used int(11) to avoid the daylight ...

Converting asp.net/sql web app to be ime zone savy

Our current app stores all dates via the server s datetime. I m thinking we need to update all datetime values in the database over to UTC time. Now for displaying these dates back to the user, I ...

Check if string is of SortableDateTimePattern format

Is there any way I can easily check if a string conforms to the SortableDateTimePattern ("s"), or do I need to write a regular expression? I ve got a form where users can input a copyright date (as a ...

DateTime in PropertyGrid in .Net

I m currently working on some DateTime properties in a PropertyGrid in c#.Net. Im using the default drop-down datetime picker. My question: Is there any way to show the full date with the time? By ...

热门标签