how to conver datetime (mm//dd//yyyy) to (dd//mm//yyyy) in ASP.Net using C#

Asked By arish chaithanya
09-Feb-10 06:45 AM
Earn up to 0 extra points for answering this tough question.
i want to convert Date from (mm//dd//yyyy) in asp.net application to (dd//mm//yyyy) .

please help me out with this


Regards,
Chaitan

  re: how to conver datetime (mm//dd//yyyy) to (dd//mm//yyyy) in ASP.Net using C#

Huggy Bear replied to arish chaithanya
09-Feb-10 06:57 AM
string mmddyyyy = "12/28/2009";
string ddmmyyyy = Convert.ToDateTime(mmddyyyy).ToString("dd/MM/yyyy")


Also slash should be single and not double.

  re: how to conver datetime (mm//dd//yyyy) to (dd//mm//yyyy) in ASP.Net using C#

Sakshi a replied to arish chaithanya
09-Feb-10 07:00 AM

You can also do like this,

DateTime dt;

dt.CustomFormat = "mm/dd/yyyy HH:mm:ss";

  re: how to conver datetime (mm//dd//yyyy) to (dd//mm//yyyy) in ASP.Net using C#

Lalit M. replied to arish chaithanya
09-Feb-10 07:09 AM
show this
http://p2p.wrox.com/general-net/27350-convert-mm-dd-yyyy-dd-mm-yyyy.html
  re: how to conver datetime (mm//dd//yyyy) to (dd//mm//yyyy) in ASP.Net using C#
Sandra Jain replied to arish chaithanya
09-Feb-10 07:36 AM
I tried using this piece of code:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dt As DateTime
        dt = "2/13/2009"
        Dim str As String = dt.Day & "/" & dt.Month & "/" & dt.Year
        MsgBox(str)
    End Sub

Output

13/2/2009
Create New Account