0

I had an issue like this. In my development environment, when I read the record from SQL Database: 12:00:00.000, the convertion always return 12PM in my application. But in the customer environment, it always return 12AM....and of course it's wrong

Have you ever faced this issue?

Thank & best regards,

4

2 回答 2

2

假设 "12:00:00.000" 是 a string,考虑DateTime使用以下方法调用将其转换为 a :

string myValue = "12:00:00.000";
DateTime myDate = DateTime.ParseExact(myValue, "HH:mm:ss:fff");

使用HH 作为小时,使用 24 小时日期格式。

请记住:这只适用于输入中指定的确切格式。

于 2013-03-13T09:36:10.180 回答
1
return DateTime.ParseExact("12:00:00.000", "HH:mm:ss:fff");
于 2013-03-13T09:40:05.750 回答