how to convert : 7/30/2010 11:05:53 AM
to : 30/07/2010
how to convert : 7/30/2010 11:05:53 AM
to : 30/07/2010
DateTime temp = DateTime.Parse("7/30/2010 11:05:53 AM");
string converted = temp.ToString("dd/MM/yyyy");
-- Using Try Parse ---
// Try Parse is better because if the format is invalid an exception is not thrown.
DateTime temp;
string converted = string.Empty;
if (DateTime.TryParse("7/30/2010 11:05:53 AM", out temp))
{
// True means Date was converted properly
converted = temp.ToString("dd/MM/yyyy");
}
else
{
converted = "ERROR in PARSING";
}
I belive you can use DateTime.Parse("7/30/2010 11:05:53 AM").ToShortDate()
(depending on the culture)
Try
DateTime dtTest = Convert.ToDateTime("7/30/2010 11:05:53 AM");
Response.Write(dtTest.ToString("dd/MM/yyyy"));