borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (change password page)Next Topic (Help with WScript) New Topic New Poll Post Reply
AndreaVB Forum : ASP.Net : DateFormat in C#?
Poster Message
tri_inn
Level: Regular User
Registered: 26-08-2002
Posts: 395

icon DateFormat in C#?

i work with vb.net,in vb.net we can format date like
Format(TextBox1.text,"dd/MM/yyyy"). but this kind of syntax is not available in C#
so please give me the above syntax in C# means syntax like Format(TextBox1.text,"dd/MM/yyyy").

21-09-2004 at 03:45 PM
View Profile Send Email to User Show All Posts | Quote Reply
zimcoder
Level: VB Lord


Registered: 27-10-2003
Posts: 225
icon Re: DateFormat in C#?

Play around with this and it will make sense in a short while
DateTime dt = DateTime.Now;
DateTimeFormatInfo dfi = new DateTimeFormatInfo();
CultureInfo ci = new CultureInfo("de-DE");

// Make up a new custom DateTime pattern, for demonstration.
dfi.MonthDayPattern = "MM-MMMM, ddd-dddd";

// Use the DateTimeFormat from the culture associated
// with the current thread.
Console.WriteLine( dt.ToString("d") );  
Console.WriteLine( dt.ToString("m") );

// Use the DateTimeFormat from the specific culture passed.
Console.WriteLine( dt.ToString("d", ci ) );

// Use the settings from the DateTimeFormatInfo object passed.
Console.WriteLine( dt.ToString("m", dfi ) );

// Reset the current thread to a different culture.
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-BE");
Console.WriteLine( dt.ToString("d") );


____________________________
BrainBench ADO.NET and ASP.NET Certified Developer

24-09-2004 at 11:04 AM
View Profile Send Email to User Show All Posts | Quote Reply
chrishelpme
Level: Trainee

Registered: 04-03-2005
Posts: 1
icon Re: DateFormat in C#?

public string GetDateTime()
{
return DateTime.Now.ToString("F",CultureInfo.CurrentCulture);
}


//use this function to get the current date time based on the culture you are in.  Change "F" to display any format you want.

04-03-2005 at 03:03 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : ASP.Net : DateFormat in C#?
Previous Topic (change password page)Next Topic (Help with WScript) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder