Forum Moderators: open

Message Too Old, No Replies

Formatting Date

         

zxk105

2:23 pm on Oct 6, 2004 (gmt 0)

10+ Year Member



I am trying to figure out how you format the date in ASP.NET in C# so it is displayed as:

October 06, 2004

This is what I have:

protected void Page_Load(Object s, EventArgs e)
{
lblDate.Text = DateTime.Now.ToString();
}

AND

Today's date: <asp:label ID="lblDate" runat="server"></asp:label>

I just can't find any examples of how you format it so it looks the way I want it. Thanks....

mattglet

3:59 pm on Oct 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



protected void Page_Load(Object s, EventArgs e)
{
lblDate.Text = DateTime.Now.ToString("MMMM dd, yyyy");
}

Here's a 4Guys [aspfaqs.com] article that I found that explains it.

zxk105

5:18 pm on Oct 6, 2004 (gmt 0)

10+ Year Member



Thanks! It works like a charm. I knew there had to be a correct format but I just couldn't find it. Thanks again....