Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have to convert any datetime format to dd/mm/yyyy format. how i can do this.i have try this but not working.


(Convert.ToDateTime(txt_NextPaymentDate.Text).ToString("dd/MM/yyyy"))
Posted
Comments
Zoltán Zörgő 25-Jan-13 7:11am    
It depends what's in txt_NextPaymentDate.Text. What have you tried?
OriginalGriff 25-Jan-13 7:12am    
"i have try this but not working."
Is not a helpful error report - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Deenuji 25-Jan-13 7:32am    
sir my doubt is
http://www.codeproject.com/Questions/534270/howplustoplusbindpluslistboxplusitemsplustoplusgri

check out Link1[^] or

Link2[^] for more details in datetime format
 
Share this answer
 
DateTime dt = DateTime.ParseExact(yourObject.ToString(), "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);

string s = dt.ToString("dd/MM/yyyy");
 
Share this answer
 
v2
Hii Professional

i think its helpfull for you....

C#
DateTime dt = DateTime.ParseExact(txt_NextPaymentDate.Text.ToString(), "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);

string s = dt.ToString("dd/M/yyyy");
 
Share this answer
 
Comments
fjdiewornncalwe 23-Feb-13 11:28am    
My 1. Same answer as Solution 1. Reported as repost.
Try this one:
C#
String.Format(@"{0:dd\/MM\/yyyy}", Convert.ToDateTime(txt_NextPaymentDate.Text))

This one gives 01/01/2012, so it works:
C#
String.Format(@"{0:dd\/MM\/yyyy}", Convert.ToDateTime("2012-01-01"))
 
Share this answer
 
C#
Convert.ToDateTime(dateString, System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat).ToShortDateString();
 
Share this answer
 
v2
HI,

Checkout the following link for the formating purpose in the date and time case.

string-format-datetime

Thanks
 
Share this answer
 

Try this one,
C#
IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
DateTime fDate = DateTime.Parse(urTxtBoxId.Value, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);

string date=fDate.ToString("dd/MM/yyyy"))

 
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