C
C#17mo ago
danno8524

❔ Date Formatting in C#

I have an incoming date of string as 202302220811 and would like to convert this to 02/22/23 08:11 AM. What is the syntax for doing this. Convert.ToDate does not like the string....
2 Replies
rotor_
rotor_17mo ago
You should be able to pass a custom parse string of your own hang on I'll check the documentation Looks as though it's
DateTime dt = DateTime.ParseExact(dateString, "ddMMyyyy",
CultureInfo.InvariantCulture);
DateTime dt = DateTime.ParseExact(dateString, "ddMMyyyy",
CultureInfo.InvariantCulture);
Although in your case we'd also parse the hour & minute Looks like it'd be yyyyMMddHHmm for you
Accord
Accord17mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts