Relative Content

Tag Archive for c#datetime

DateTime ParseExact throws FormatException for only PM times

I have a list of different DateTime formats and I want to convert all of them in one specific format. It works fine, until I hit this line: 9.13.2023 2:06:58 PM. On this line i get an System.FormatException. But the line 9.13.2023 6:38:50 AM works fine. Do i overlook something?

DateTime not returning Time portion

I have a string that I’m trying to convert into a 24hr DateTime. So far the closest thing I’ve found to work is doing a substring on the values and then creating a new DateTime using those values. However, even though in Debug I can see it’s setting hours, minutes, seconds, the value returned is just the Date and not the DateTime. Am I missing something to accommodate returning Date and Time?