C# .NET - How do I format a date displayed in a textbox?

Asked By Sabrina Spillane on 09-May-06 11:54 AM
I have a textbox in my form that will contain todays date and I am prefilling it as follows:
DateTime timeNow = DateTime.Now;
this.txtDate.Text = timeNow.ToShortDateString();
How can I format this date to display the current date as "May 9, 2026"?
Thanks in advance again for all the help.

DateTime Format

Asked By Ramya T on 09-May-06 12:03 PM
DateTime timeNow = DateTime.Now; 
this.txtDate.Text = timeNow.ToString("m") + timeNow.Year.ToString();

You can add Comma in between like this

Asked By Ramya T on 09-May-06 12:07 PM
DateTime timeNow = DateTime.Now; 
this.txtDate.Text = timeNow.ToString("m") + ", " + timeNow.Year.ToString();

ToString

Asked By F Cali on 09-May-06 12:11 PM
Another way to do is using the following:
this.txtDate.Text = timeNow.ToString("MMMM dd, yyyy");
Thanks
Asked By Sabrina Spillane on 09-May-06 12:15 PM
That worked great, thanks for all the help.