How to convert the below string to DateTime
in C#?
Mon Apr 22 07:56:21 +0000 2013
When i tried the code with
Convert.ToDateTime("Mon Apr 22 07:56:21 +0000 2013")
it is throwing error as
String was not considered as valid DateTime
How to convert the below string to DateTime
in C#?
Mon Apr 22 07:56:21 +0000 2013
When i tried the code with
Convert.ToDateTime("Mon Apr 22 07:56:21 +0000 2013")
it is throwing error as
String was not considered as valid DateTime
You have basically two options for this. DateTime.Parse() and DateTime.ParseExact(). like
You can use this:
If you run program from country with +06:00, you get time 13:56:21 with same date
You have to specify that your input string is in a particular format. Please refer this link and this one too.
Use
DateTime.ParseExact
like:Try
DateTime.ParseExact
instead.Example:
More examples are available at http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx