How to change a DateTime Format

Posted by Carlo Adap on Stack Overflow See other posts from Stack Overflow or by Carlo Adap
Published on 2012-08-25T10:07:29Z Indexed on 2012/08/28 3:38 UTC
Read the original article Hit count: 164

Filed under:
|
List<DateTime> datetimerange = new List<DateTime>();

DateTime StartDate = Convert.ToDateTime(txtDate.Text);
DateTime EndDate = Convert.ToDateTime(TextBox1.Text);
foreach (DateTime day in EachDay(StartDate, EndDate))
{
     datetimerange.Add(day.Date);
     Session["SelectedDatess"] = datetimerange;
}

When I displays it to a list box the date looks like 8/28/2012 12:00:00 whereas I just want to display 8/28/2012.

How can I change the format of the date to MM/dd/yyyy?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET