Search
Categories
  ASP.NET
Visual C#
Visual Basic
.NET Framework
ADO.NET
AJAX
LINQ
Java
 
How To Rating
 
5.0 out of 5


Total Votes: 1
         
1 2 3 4 5
 




How to convert a string into valid DateTime object

Author: Waqas Anwar - Posted Date: 16-July-2009 - Category: .NET Framework   
Bookmark and Share
If you have a string in your program which is convertible into a valid DateTime object you can use Parse method of DateTime class as shown in following examples:
string s = "12-January-2008";
DateTime d = DateTime.Parse(s);

s = "12-Mar-2008";
d = DateTime.Parse(s);

s = "12-25-2008";
d = DateTime.Parse(s);

Note that the Parse method throws FormatException if your string is not valid and not convertible into valid DateTime object.
LEAVE YOUR COMMENTS LEAVE YOUR COMMENTS
 Name (required)  
 Email (required
 Website


 

 


 
 
 

Categories

My Portfolio

Website Links


Copyright @ 2009 EzzyLearning.com