Click here to Skip to main content
16,007,885 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
01-05-2012

convert this into., Tue,1 May,2012

using c#
Posted

Assuming 01-05-2012 is a string, first convert it to a DateTime:
C#
DateTime dt = DateTime.ParseExact("01-05-2012", "dd-MM-yyyy", CultureInfo.InvariantCulture);
Then you can format the DatetIme as you wish:
C#
string s = dt.ToString("ddd,d MMM,yyyy");

There is a full list of the formatting strings here: Formatting a DateTime for display - format string description[^]
 
Share this answer
 
Do this:


C#
DateTime dt = Datetime.Now;

string date = String.Format("{0:ddd, d MMM, yyyy}", dt); 

//or

string s = dt.ToString("ddd, d MMM, yyyy");
 
Share this answer
 
v3
Comments
VJ Reddy 15-May-12 4:42am    
Good answer. 5!
You can Do this:

string dt=Convert.ToDateTime("01 - 05 - 2012").ToLongDateString();

Hope this is helpful for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900