Reputation: 62434
how to convert : 7/30/2010 11:05:53 AM
to : 30/07/2010
Upvotes: 2
Views: 130
Reputation: 73301
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";
}
Upvotes: 4
Reputation: 829
I belive you can use DateTime.Parse("7/30/2010 11:05:53 AM").ToShortDate()
(depending on the culture)
Upvotes: 0