tags:

views:

42

answers:

4

how to convert : 7/30/2010 11:05:53 AM

to : 30/07/2010

+4  A: 
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";
}
David Basarab
.NET is beautiful sometimes
Robert Karl
Doesn't anyone here use TryParse?
fletcher
@fletcher ask and you shall receive.
David Basarab
A: 
DateTime.ToString("dd/MM/yyyy");
šljaker
A: 

I belive you can use DateTime.Parse("7/30/2010 11:05:53 AM").ToShortDate() (depending on the culture)

JWL_
A: 

Try

 DateTime dtTest = Convert.ToDateTime("7/30/2010 11:05:53 AM");
            Response.Write(dtTest.ToString("dd/MM/yyyy"));
Prakash Kalakoti