hi
how to ask in C# Winform if this format: ddd MMM d HH:mm:ss yyyy
== true
then convert to dd/MM/yyyy
format
thank's in advance
hi
how to ask in C# Winform if this format: ddd MMM d HH:mm:ss yyyy
== true
then convert to dd/MM/yyyy
format
thank's in advance
Use TryParseExact(). Followed by DateTime.ToString() to convert. For example:
public static string ConvertDate(string arg) {
DateTime dt;
if (DateTime.TryParseExact(arg, "ddd MMM d HH:mm:ss yyyy", null,
System.Globalization.DateTimeStyles.AssumeLocal, out dt)) {
return dt.ToString("dd/MM/yyyy");
}
// Consider what to return on failure...
return null;
}
Test case:
string s = ConvertDate("Fri Jul 23 10:21:00 2010");