C# DateTime Parsing

Question posted in Computer Software on 09 2009
Rate question difficulty level 0 Votes
Given a string in an unknown datetime format.
How would you "load" it into a datetime object?

example : String dateStr = ''20090929181523"
 
 
1 Answer
 
The datetime object has a static Parse method which allows the user to
"load" any datetime in any legal format.

String dateStr = ''20090929181523"
DateTime.Parse(dateStr)

If the format is known , the ParseExact method can be used.

Futher reading
http://msdn.microsoft.com/en-us/library/1k1skd40.aspx
http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx


09/29/2009
 
 
Add an answer*
 
Email
Location: Glil Yam , Israel
c# datetime
Now hiring!
Intuit 
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------