how to convert date time format as yyyyddmm hh:mm:ss in c#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    how to convert date time format as yyyyddmm hh:mm:ss in c#?

    i am getting date format in string as 30-11-2006 05:59:44 PM . i want to convert in the format of yyyy-mm-dd hh:mm:ss to sore it in mysql database.
    Help me with sample coding plz..
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Try placing your date in a string and then form it:
    Code:
    myDate.ToString("yyyy-MM-dd hh:mm:ss")
    OR
    Code:
    myDate.DateFormat = "yyyy-MM-dd hh:mm:ss";
    Hope that this helps.

    Comment

    • Jimmy611
      New Member
      • Jan 2007
      • 49

      #3
      DateTime.Now.To String("yyyy/MM/dd HH:MM")

      Comment

      • radcaesar
        Recognized Expert Contributor
        • Sep 2006
        • 759

        #4
        Try with,

        DateTime.Custom Format()

        :)

        Comment

        • nirmalsingh
          New Member
          • Sep 2006
          • 218

          #5
          its rarely working well with
          myDate.ToString ("yyyy-MM-dd hh:mm:ss")
          but i have an error often as internal server error

          Comment

          • kenobewan
            Recognized Expert Specialist
            • Dec 2006
            • 4871

            #6
            May be unrelated:
            500 Internal Server Error Resolution

            But suggest you post code in case. Does error give you a line number?

            Comment

            Working...