简体   繁体   English

总是将12:00:00.000转换为12AM问题

[英]Convert 12:00:00.000 always to 12AM issue

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. 在开发环境中,当我从SQL数据库中读取记录:12:00:00.000时,该转换在我的应用程序中始终返回12PM。 But in the customer environment, it always return 12AM....and of course it's wrong 但是在客户环境中,它总是返回12AM ....当然,这是错误的

Have you ever faced this issue? 您曾经遇到过这个问题吗?

Thank & best regards, 谢谢与最诚挚的问候,

Assuming "12:00:00.000" is a string , consider converting it to a DateTime using the following method call: 假设“ 12:00:00.000”是一个string ,请考虑使用以下方法调用将其转换为DateTime

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

Using HH as the hour , a 24h date format is used. HH用作小时 ,则使用24小时日期格式。

Remember: this only works in the exact format specified in the input. 请记住:这仅适用于输入中指定的确切格式。

return DateTime.ParseExact("12:00:00.000", "HH:mm:ss:fff");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM