Click here to Skip to main content
15,923,168 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hai,
I need to convert paricular date to string.

Ex:txtbox.text();(15/05/2012) to May,2012

Please help me
Posted

A DateTime object can be set to string like
C#
txtbox.text = myDateTime.ToString("MMM,yyyy");
 
Share this answer
 
v3
Comments
fjdiewornncalwe 14-Feb-12 9:36am    
I took the liberty of fixing the "MM" to "MMM" as it needs to be in your string format arg. +5.
Herman<T>.Instance 14-Feb-12 10:57am    
liberty granted ;)
Abhinav S 14-Feb-12 9:52am    
5!
Use the DateTime.ToString method with a custom format (see MSDN[^]), for instance
C#
DateTime dt = new DateTime(2012, 5, 15);
txtbox.Text = dt.ToString("MMM,yyyy");
 
Share this answer
 
v2
Comments
Abhinav S 14-Feb-12 9:52am    
5!
If you want to do the other way around, i.e. not to format a DateTime object into String, but to convert a String into a DateTime object, you can use DateTime.Parse(...) functions. The references are all there in MSDN you should be fine with them.
 
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