DateTime convertion
-
Hi, I want to convert the below string to DateTime object . I am unable to do this using Convert.ToDateTime() Wed Feb 24 04:56:30 2010 Please suggest. Please provide regular expression if required. Thanks,
-
Hi, I want to convert the below string to DateTime object . I am unable to do this using Convert.ToDateTime() Wed Feb 24 04:56:30 2010 Please suggest. Please provide regular expression if required. Thanks,
If it is always going to be in that format, then you could use String.Split to break it on the spaces, and then re-assemble for conversion, or use Convert.ToInt repeatedly in a DateTime constructor.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
Hi, I want to convert the below string to DateTime object . I am unable to do this using Convert.ToDateTime() Wed Feb 24 04:56:30 2010 Please suggest. Please provide regular expression if required. Thanks,
Look about DateTime.ParseExact and Custom DateTime format strings. You can parse your date using
DateTime.ParseExact("Wed Feb 24 04:56:30 2010", "ddd MMM dd HH:mm:ss yyyy", System.Globalization.CultureInfo.InvariantCulture);
-
Look about DateTime.ParseExact and Custom DateTime format strings. You can parse your date using
DateTime.ParseExact("Wed Feb 24 04:56:30 2010", "ddd MMM dd HH:mm:ss yyyy", System.Globalization.CultureInfo.InvariantCulture);
Thank you it is working.
-
Hi, I want to convert the below string to DateTime object . I am unable to do this using Convert.ToDateTime() Wed Feb 24 04:56:30 2010 Please suggest. Please provide regular expression if required. Thanks,
The Convert class is rarely the best way to do anything; avoid it.