C# Date Formats using ToString Function in ASP.Net

When you use C# ToString function with DateTime variable it allows you to specifiy the type of Date format you want to display on the ASP.Net web page. DateTime formats are the combination of few characters that return the specified formats, the characters for Date format specifier are M for month, d for day, y for year. All these specifier characters are case sensitive.

Following are few examples of format specifiers that can be passed as a string to the C# ToString Function:

You can try the following sample by specifying different date styles:

Enter Date:
Format Style Output
MM-dd-yyyy : 05-24-2013
MMM dd, yyyy : May 24, 2013
ddd MM, yyyy : Fri 05, 2013
dddd MM, yyyy : Friday 05, 2013
MMM ddd dd, yyyy : May Fri 24, 2013
MMMM ddd dd, yyyy : May Fri 24, 2013
MMMM dddd dd, yyyy : May Friday 24, 2013
  • HIRE EzineASP.Net Developers