How can I convert a string such as "Wed Mar 08 21:21:38 2006" into a DateTime?
What I'm trying to do is reformat a date in that string into a date that looks like "03/08/06 21:21:38".
Printable View
How can I convert a string such as "Wed Mar 08 21:21:38 2006" into a DateTime?
What I'm trying to do is reformat a date in that string into a date that looks like "03/08/06 21:21:38".
This creates a Date object that corresponds to the string in the specified format, then creates another String that corresponds to that date in the second format. Doing it in one line like this loses the Date object. If you want to keep it you could separate the operation into multiple lines. That way you can use the date object for other purposes, like calculations.VB Code:
Dim myDateString As String = Date.ParseExact("Wed Mar 08 21:21:38 2006", "ddd MMM dd HH:mm:ss yyyy").ToString("MM/dd/yy HH:mm:ss")
Thank you. That's exactly what I was looking for.
Cool. Don't forget to resolve your thread from the Thread Tools menu.