I have following string "16:07:57.796" how i can parse it to this 6/18/2011 16:07:57 ?
If I just try to parse it DateTime.Parse("16:07:57.796") I get 6/18/2011 04:07:57 PM
And it's not what I need.
Thanks for help.
It is parsed correctly (as 4 pm is 16) but it is your locale information which displays it differently than you want. You should use the following ToString method, which takes an IFormatProvider, in which you can pass in a CultureInfo that fits you.
Otherwise you can format your string using custom date and time formats like the following:
date.ToString("M/dd/yyyy HH:mm:ss")
6/18/2011 16:07:57is only a string representing that DateTime. you can get a string with any format from your DateTime