Click here to Skip to main content
11,648,960 members (82,418 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 25-Jan-13 1:07am
Comments
Zoltán Zörgő at 25-Jan-13 7:11am
   
It depends what's in txt_NextPaymentDate.Text. What have you tried?
OriginalGriff at 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 at 25-Jan-13 7:32am
   
sir my doubt is
http://www.codeproject.com/Questions/534270/howplustoplusbindpluslistboxplusitemsplustoplusgri
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

check out Link1[^] or

Link2[^] for more details in datetime format
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

DateTime dt = DateTime.ParseExact(yourObject.ToString(), "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
 
string s = dt.ToString("dd/MM/yyyy");
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hii Professional

i think its helpfull for you....

DateTime dt = DateTime.ParseExact(txt_NextPaymentDate.Text.ToString(), "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
 
string s = dt.ToString("dd/M/yyyy");
  Permalink  
Comments
Marcus Kramer at 23-Feb-13 11:28am
   
My 1. Same answer as Solution 1. Reported as repost.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this one:
String.Format(@"{0:dd\/MM\/yyyy}", Convert.ToDateTime(txt_NextPaymentDate.Text))
This one gives 01/01/2012, so it works:
String.Format(@"{0:dd\/MM\/yyyy}", Convert.ToDateTime("2012-01-01"))
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

Convert.ToDateTime(dateString, System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat).ToShortDateString();
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

HI,

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

string-format-datetime

Thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5


Try this one,
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"))
  Permalink  

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

  Print Answers RSS
0 F-ES Sitecore 419
1 CPallini 410
2 Kornfeld Eliyahu Peter 330
3 OriginalGriff 324
4 Sergey Alexandrovich Kryukov 254
0 OriginalGriff 1,512
1 Sergey Alexandrovich Kryukov 1,022
2 jyo.net 994
3 DamithSL 986
4 CPallini 945


Advertise | Privacy | Mobile
Web02 | 2.8.150804.4 | Last Updated 25 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100