简体   繁体   中英

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. But in the customer environment, it always return 12AM....and of course it's wrong

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:

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.

Remember: this only works in the exact format specified in the input.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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