My MySQL database has a date field in the format:
yyyy-mm-dd
but in ASP .NET this shows as:
9/14/2009 12:00:00 AM
in both the ItemTemplate and EditItemTemplate.
How do I format the field to display properly?
My MySQL database has a date field in the format:
yyyy-mm-dd
but in ASP .NET this shows as:
9/14/2009 12:00:00 AM
in both the ItemTemplate and EditItemTemplate.
How do I format the field to display properly?
You can use ToShortDateString() method of DateTime. You also can use something like this:
DateTime dateTimeObject = Convert.ToDateTime("9/14/2009 12:00:00 AM");
dateTimeObject.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);