Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I want to display date in dd mmm yyyy format in C#
like 21st Jan 2010
how to do that..

Thanks.
Posted

C#
System.DateTime a = default(System.DateTime);
a = Strings.Format(DateAndTime.Now.Date, "dd MMM yyyy")
 
Share this answer
 
Comments
dev22 12-Dec-11 4:15am    
Hi NikulDarji,
thanks but i got error that format method does not exist..
can i get namespace for Strings.Format()
NikulDarji 12-Dec-11 8:47am    
u r right it was my mistake...the month should be like "MMM", i m improving my solution...sorry for whatever happened....
Richard MacCutchan 12-Dec-11 9:18am    
There is no Strings class in .NET.
C#
DateTime.Now.ToString("dd MMM yyyy");


see here[^] for more details.
 
Share this answer
 
Comments
dev22 12-Dec-11 4:34am    
Thanks koolprasad2003
try :
C#
DateTime dt = DateTime.Now;
           string date= String.Format("{0:D}", dt);


this will display the date as :Monday, December 12, 2011

for more date formats refer:http://www.csharp-examples.net/string-format-datetime/[^]
 
Share this answer
 
Have a look at Custom Date and Time Format Strings[^] to format your date field into the appropriate format.

http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^] provides more information.

You can go through DateTime Formatting[^] as well.
 
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